Netlify Integration
If your site is hosted on Netlify (with any framework — Next.js, Astro, Hugo, Gatsby, Eleventy, or static HTML), you can integrate SEOJuice with a script tag or use Edge Functions for server-side rendering.
Option 1: Client-Side Script (Quick Setup)
Add the SEOJuice script tag before </body> in your site’s layout file:
<script type="text/javascript" src="https://cdn.seojuice.io/suggestions.v1.js" defer></script>Where to Add It
| Framework | File |
|---|---|
| Astro | src/layouts/Layout.astro |
| Hugo | layouts/_default/baseof.html |
| Gatsby | gatsby-ssr.js (or html.js) |
| Eleventy | Your base layout template |
| Static HTML | Every HTML file before </body> |
| Next.js | layout.tsx or _document.tsx (use plain <script>, not <Script>) |
Netlify Snippet Injection (Alternative)
If you don’t want to modify source code, use Netlify’s built-in snippet injection:
- Go to Site Settings → Build & Deploy → Post processing → Snippet injection
- Click Add snippet
- Set insertion to Before
</body> - Paste the script tag
- Save
This automatically injects the script into every page during Netlify’s post-processing step.
Option 2: Server-Side via Edge Functions (Advanced)
For server-side rendering, use Netlify Edge Functions with the SEOJuice Node.js SDK:
import { fetchSuggestions, injectSEO } from '@seojuice/sdk';
export default async function handler(request, context) { const response = await context.next(); const contentType = response.headers.get('content-type') || '';
// Only process HTML pages if (!contentType.includes('text/html')) { return response; }
const html = await response.text();
const suggestions = await fetchSuggestions(request.url, { baseURL: 'https://smart.seojuice.io/suggestions', timeout: 5000, });
const transformedHTML = injectSEO({ html, suggestions, injectLinks: true, injectMetaTags: true, injectStructuredData: true, });
return new Response(transformedHTML, { headers: response.headers, });}
export const config = { path: '/*', excludedPath: ['/admin/*', '/_next/*', '/api/*'],};This renders SEOJuice optimizations into the HTML at the edge, making them visible to crawlers without JavaScript.
Content Security Policy
If your site has a strict CSP (often set in netlify.toml or _headers), add:
script-src 'self' https://cdn.seojuice.io;connect-src 'self' https://smart.seojuice.io;Verify Your Integration
- Deploy your site to Netlify
- Visit the production URL
- Open DevTools → Network tab → filter for
seojuice - Confirm the script loads with 200 status
For troubleshooting, see Integration Verification.