We use cookies to keep this site working and, with your permission, to remember your preferences, understand site traffic and support advertising. You can change your choice at any time. Cookie Policy

SEO Tool Orbit
Technical SEO

JavaScript SEO: How to Make Your Website Content Search Engine Friendly

Google can run JavaScript, but that doesn't make every JavaScript site easy to index. Here's how rendering works, what tends to go wrong and how to check your own pages.

By SEO Tool Orbit7 min read

Illustration of a nearly empty code panel turning into a fully rendered web page under a magnifying glass
What your server sends and what a browser finally shows can be very different pages. · Original illustration by SEO Tool Orbit

A page built with JavaScript can look perfect in your browser and still give a search engine very little to work with. The content may arrive late, depend on a click, or exist only after a script that failed. Google can run JavaScript, but that's a long way from saying every JavaScript site is easy to index. JavaScript SEO is the work of making sure your content, links and metadata reach search engines reliably, however the site is built.

In short: put the content, title, canonical and links that matter into the HTML your server sends, using server-side or static rendering where you can. Use real <a href> links and normal URLs, return honest status codes, and never rely on JavaScript to remove a noindex. Then compare the raw HTML with the rendered HTML to find out what depends on scripts.

What JavaScript SEO means

Traditional SEO assumes the server sends a complete document. JavaScript SEO deals with the cases where it doesn't: single-page apps, content loaded from an API, and components that only appear after hydration. The questions are technical. Can the content be crawled? Does it render? Does the rendered version get indexed? Good writing that never reaches the index can't help anyone.

How Google processes JavaScript

Google's JavaScript SEO documentation describes three phases:

  1. Crawling. Googlebot checks robots.txt, fetches the URL and reads the HTML for links. Disallowed URLs are skipped, and Google won't render JavaScript from files it's blocked from fetching.
  2. Rendering. Pages that return a 200 status are queued for rendering unless a robots meta tag or header says not to index them. A page might wait a few seconds or longer. A headless Chromium then runs its JavaScript.
  3. Indexing. Google reads the rendered HTML for content and further links, and uses it for indexing.

Two practical points follow. Rendering is an extra step that can fail or be delayed, so content in the original HTML is simply the safer place for anything important. And Google is not the only reader: it notes that not all bots can run JavaScript, and link preview crawlers are a common example.

Server-side rendering, client-side rendering and the options between

ApproachWhere the HTML is builtEffect on SEOGood fit
Client-side rendering (CSR)In the browser, by JavaScriptThe first HTML is often nearly empty, so everything depends on rendering succeedingLogged-in dashboards and private tools
Server-side rendering (SSR)On the server, for each requestContent is in the first responsePublic pages that change often
Static site generation (SSG)At build time, one file per URLContent is in the first response and quick to serveArticles, documentation, marketing pages
HydrationServer HTML first, then scripts attach behaviourNo harm when the server HTML is completeInteractive pages built on SSR or SSG

As web.dev's rendering guide puts it, hydration adds state and interactivity to server-rendered HTML. It isn't a separate way of producing content, so a hydrated page is only as complete as the HTML it started with. Heavy hydration costs responsiveness instead; our Core Web Vitals guide covers how to measure and reduce that.

You may also read about dynamic rendering, which serves crawlers a pre-rendered copy while users get the client-side version. Google now calls it a workaround and not a recommended solution, and recommends server-side rendering, static rendering or hydration instead.

Common JavaScript SEO problems

  • Links that aren't links. Google discovers links from <a> elements with an href. A <div onclick> or a button that changes the route gives it nothing to follow.
  • Fragment routing. URLs like /#/products can't be reliably resolved. Use the History API and ordinary paths.
  • Content that needs an action. Google doesn't click buttons or trigger user-action scripts, so content fetched only after a click or a "load more" needs a crawlable route as well.
  • Soft 404s. A client-side router often answers every path with a 200, including pages that don't exist. Google suggests a JavaScript redirect to a URL that returns a real 404, or adding noindex to the error view.
  • Blocked resources. A robots.txt rule covering your scripts or API can leave Google rendering an empty shell.
  • Reliance on stored state. Google's troubleshooting page says Local Storage, Session Storage and cookies are cleared across page loads, and permission requests such as camera access are declined. Content mustn't depend on them.
  • Unsupported features. Googlebot doesn't support WebSockets or WebRTC, so content delivered that way needs an HTTP fallback.
  • Stale files. Google's renderer may ignore caching headers and use old JavaScript or CSS. Put a content hash in filenames, which most bundlers do by default.

How to identify content rendering issues

  1. Look at the raw HTML. Open the page in the Source Code Viewer, which shows the HTML as the server sent it. Search for a distinctive sentence, your main heading and a few important links.
  2. Look at the rendered HTML. In Search Console, inspect the URL, choose Test live URL and open View tested page. You'll see the rendered HTML, a screenshot, console messages and loaded resources. Our Search Console guide explains the tool in more detail. Without Search Console access, Google's Rich Results Test shows the rendered HTML as well.
  3. Compare the two. Text in both is safe. Text only in the rendered version depends on JavaScript and deserves a look. Text in neither isn't visible to Google at all, so check the console errors and blocked resources.
  4. Check across the site. An SEO Audit reads each page's HTML without running scripts, so anything it reports missing is missing from the first response. That's a quick way to find templates that rely on JavaScript.

If a page still isn't in the index after that, work through the reason Search Console gives, because the cause may have nothing to do with rendering.

Meta tags and canonical URLs in JavaScript applications

  • Titles and descriptions can be set or changed with JavaScript, though server output is more dependable.
  • Canonical tags belong in the HTML. If JavaScript has to set one, it should match any canonical already there, and the page should end up with exactly one. Our canonical guide covers the wider rules.
  • Noindex is the one to be careful with. When Google sees it, it may skip rendering, so JavaScript can't reliably remove it. If you want a page indexed, leave noindex out of the original HTML.
  • Open Graph tags need to be in the initial response, because many preview crawlers don't execute scripts.

In the Next.js App Router, per-page metadata is generated on the server:

export async function generateMetadata({ params }) {
  const { slug } = await params;
  const product = await getProduct(slug);
  return {
    title: product.name,
    description: product.summary,
    alternates: { canonical: `https://example.com/products/${slug}` },
  };
}

A practical checklist for Next.js and React

  • Keep public content in Server Components, and put 'use client' only on the interactive parts.
  • Don't load a page's main content in useEffect; it won't be in the first response.
  • Export metadata or generateMetadata for every public route.
  • Use next/link or plain anchors, which output a real <a href>.
  • Know how streaming affects status codes. Once a response has started streaming it stays a 200, so notFound() then relies on an injected noindex. For a true 404, check that the record exists before streaming begins.
  • Don't be alarmed if a raw fetch shows metadata late in the document. Next.js can stream it for crawlers that run JavaScript, and keeps it in the <head> for bots it identifies as HTML-only, a list you can change with htmlLimitedBots.
  • For a client-only React app, use a router based on the History API and pre-render your public pages.
  • Generate the sitemap from the same data as the routes, so the two can't drift apart.
  • Test a real production build, since development servers behave differently.

Mistakes developers should avoid

  • Testing only in your own logged-in browser, where cookies and cached data hide problems.
  • Showing crawlers substantially different content from users, which can count as cloaking.
  • Sending a paywalled article's full text and hiding it with JavaScript. Serve it only once access is confirmed.
  • Assuming that because one template renders, all of them do. Check each page type.

Frequently asked questions

Can Google index JavaScript content?

Yes, Google renders pages with a headless browser and indexes the result. It isn't guaranteed for every page, and rendering is an added step that can fail or be delayed.

Is server-side rendering required for SEO?

No, but Google describes server-side or pre-rendering as still a great idea, because it makes sites faster for users and crawlers and not all bots can run JavaScript.

Does hydration hurt SEO?

Not on its own, because the content is already in the server HTML. It can affect responsiveness if the page ships a lot of JavaScript.

Do other search engines render JavaScript?

Capabilities vary and aren't all documented, so the dependable approach is to put important content in the initial HTML.

Next step

Pick your most important page template and open one URL in the Source Code Viewer. If the main heading, body text and links are there, that template is in good shape. If they aren't, compare it with the rendered HTML in Search Console and decide what should move to the server.