freecourses.digital
Lesson progress: 0 of 3 activities done
All lessons in Technical SEO Auditing Lesson 8.4 of 84

JavaScript-Generated Content and Links

In this lesson

  • Which JavaScript link patterns Google can follow
  • How to find content only present after rendering
  • How hash and fragment URLs affect crawling
  • How to recommend crawlable alternatives

Short answer

Google follows only real links: an <a> element with an href that resolves to a URL. Links built with onclick handlers, buttons, or hash fragments are not crawled as separate pages. Audit by comparing raw and rendered crawls for rendered-only content and links, then recommend real href links and content present in the initial HTML.

A Manila online grocery had a beautiful category menu. Each item was a <div> that ran goTo('vegetables') on click. Users had no problem. Googlebot found no links at all, and most category pages ended up orphaned in Google’s eyes.

Google follows these:

<a href="/vegetables/">Vegetables</a>
<a href="/vegetables/" onclick="track()">Vegetables</a>

Google follows both links above. It does not follow any of the links below (the last one only jumps to a spot on the same page):

<span onclick="goTo('vegetables')">Vegetables</span>
<a onclick="goTo('vegetables')">Vegetables</a>
<a href="javascript:goTo('vegetables')">Vegetables</a>
<a href="#vegetables">Vegetables</a>

How to audit

  1. Crawl twice: once text-only, once with JavaScript rendering.
  2. Compare discovered URLs: pages found only in the rendered crawl depend on JavaScript links.
  3. JavaScript tab filters: “Contains JavaScript links” and “Contains JavaScript content.”
  4. Check navigation templates in DevTools: menus, filters, pagination, related products.
  5. Check fragment routing: URLs with #/ patterns usually mean a single page app needing real paths.

Recommendations

  • Convert navigation to <a href> elements (scripts can still enhance them).
  • Use History API routes, not hash fragments.
  • Render main content and key links on the server.
  • Back infinite scroll and “load more” with paginated URLs.

Practice: crawlable or not?

Sort each item into the right group.

  • <a href="/fruits/">Fruits</a>

  • <div onclick="open('/fruits/')">Fruits</div>

  • <a href="#/fruits">Fruits</a>

  • <a href="/fruits/" onclick="track()">

  • <button>Next page</button> with no URL

Common mistakes

  • Testing links only in a browser. Everything works for users.
  • Auditing only rendered crawls. You miss which links depend on JavaScript.
  • Hash-based routing in single page apps.
1. Which link does Google reliably follow?
2. How do you find links that depend on JavaScript?
3. Are /shop#shoes and /shop indexed separately?

Your action

Next, you will diagnose rendering failures and missing content.

Key terms

Crawlable link
An <a href="/path/"> element that resolves to a real URL.
onclick navigation
Navigation triggered by a script on click, without an href. Not followed by Google.
Fragment URL
A URL part after #, such as /shop#shoes. Google generally ignores fragments for indexing.
History API routing
Routing that changes the URL path with pushState, producing real crawlable URLs when links have hrefs.

Questions beginners ask

Can Google follow a <span> with a click event?

No. Only <a> elements with href attributes are reliably followed.

Are hash URLs indexed separately?

Generally no. /page#section is treated as /page. Single page apps should use real paths with the History API.

Is content added by JavaScript indexed?

Usually, if it renders on load without interaction. It is slower and less reliable than content in the raw HTML.

What about infinite scroll?

Provide paginated URLs with real links, so crawlers can reach items without scrolling.

Related lessons

Want someone to handle SEO for your business while you learn? The team at Remar Digital can help.