Why it matters
- Google reads a page twice: its HTML as the server sends it, then, often later, the page its scripts make. Its JavaScript SEO guide says not to use a script "to change the canonical URL to something else than the URL you specified", and that a canonical a script adds must be "the only rel="canonical" link tag on the page".
- When the two disagree, which address Google keeps as the page's own is not what either says for sure.
- On
noindex, the same guide says: "When Google encounters the noindex tag, it may skip rendering and JavaScript execution", so removing it with a script "may not work as expected". A page meant to be indexed should not saynoindexin its HTML. - A script may set the canonical where the HTML has none, set the title and the description, or add a
noindex(to an error page, say): Google's guide allows all of these, and this check does not report them.
Example
<script> document.querySelector('link[rel="canonical"]').href = '/ar/oud/' </script>
<link rel="canonical" href="/ar/oud/" />
How to fix
Write the canonical and the robots meta the page should have in its HTML, and let no script change them:
html
<link rel="canonical" href="/ar/oud/" />- If a theme or a plugin rewrites the canonical in the browser, turn that off, or have the server write the right address.
- If a page starts as
noindexuntil a script decides, decide on the server instead.
How we detect
- We read the canonical link and the robots and googlebot metas in the HTML's
<head>, as the server sent it. - We render the page in Chromium, the engine Google renders with, and read the same in the head the scripts left.
- We report a canonical the scripts changed to another address, more than one canonical after the scripts ran, and a
noindexin the HTML that the scripts removed. AnoindextheX-Robots-Tagheader sends cannot be removed by a script, and is not judged here;page-noindexreports everynoindex.