Skip to content

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

FrameworkFile
Astrosrc/layouts/Layout.astro
Hugolayouts/_default/baseof.html
Gatsbygatsby-ssr.js (or html.js)
EleventyYour base layout template
Static HTMLEvery HTML file before </body>
Next.jslayout.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:

  1. Go to Site SettingsBuild & DeployPost processingSnippet injection
  2. Click Add snippet
  3. Set insertion to Before </body>
  4. Paste the script tag
  5. 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:

netlify/edge-functions/seojuice.ts
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

  1. Deploy your site to Netlify
  2. Visit the production URL
  3. Open DevTools → Network tab → filter for seojuice
  4. Confirm the script loads with 200 status

For troubleshooting, see Integration Verification.