When scripts change what search engines read
The HTML your server sends and the page after its scripts ran can say different things. Why that matters for titles, canonicals and noindex.
Open a page, choose "view source", and you see what the server sent. Open the inspector and you see the page as it is now, after its scripts ran. On many sites these two are not the same document.
Two versions of one page
<title>Loading...</title>
<meta name="robots" content="noindex">
<div id="app"></div><title>Trail running shoes · Example</title>
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://example.com/shoes/trail">
<div id="app">...the whole page...</div>A person only ever sees the second. A crawler starts with the first, and what it does next depends on which crawler it is.
Who reads which
- Google fetches the HTML first and renders the page with scripts afterwards, as a separate step that can come later.
- Many other crawlers, including the ones behind link previews in chat and social apps, read only the HTML the server sent.
So a title, a description or a preview image that only scripts add will be missing for part of your audience, even when the page looks complete in a browser.
When the two disagree
Missing information is one problem. Conflicting information is a worse one, because a crawler may act on either version.
- noindex removed by a script. Google says that when it finds noindex in the HTML, it may skip rendering. The script that would have removed it never runs.
- A canonical that changes. The server names one address and the script names another. Which one is used is no longer up to you.
- Links that appear late. Navigation that scripts build is invisible to a crawler that does not run them, so the pages behind it look like nothing links to them.
What to do
- Send the head from the server. Title, description, canonical, robots and link-preview tags belong in the first response.
- Do not let scripts change them. If they must set them, they should set the same values the server sent.
- Compare both versions. Fetch the page without scripts, render it with them, and look at the difference in the tags that matter.
curl -s https://example.com/shoes/trail | grep -iE '<title|rel="canonical"|name="robots"'With Ranky
Ranky opens pages in a real browser as well as fetching their HTML, and reports where the two say different things, with both values side by side. Rendered pages also get the checks that need a browser: script errors, failed requests, layout and accessibility.
What counts as a rendered page on each plan is on Pricing, and the checks are listed in Checks.
