Lorixen.
EN

Google ignoring your canonical or noindex? Check the HTML head

Short answer: Google reads the metadata in your page's <head>, but only valid head elements count. Its documentation says that when it finds an invalid element there, such as an <img> or <iframe>, it assumes the head has ended and ignores everything after it. If a tracking snippet, chat widget or plugin injects one of those near the top, your canonical, robots meta, hreflang and social tags below it can be silently ignored. View the rendered head, move invalid elements to the body, and put your important SEO tags as early as possible.

The rule, from Google's documentation

Google Search Central lists the elements allowed inside <head>, matching the HTML standard:

  • title
  • meta
  • link
  • script
  • style
  • base
  • noscript
  • template

It names iframe and img as common invalid elements found in the head. If you use one, Google "ignores any elements that appear after the invalid element", treating it as the end of the head. Google recommends not using them there at all, and if you must, placing them after the elements you want Google to see.

MDN's reference for <head> describes the same standard: the head holds metadata content, with exactly one <title>.

Why this happens on real sites

Nobody writes <img> into the head on purpose. It arrives through:

  • Tracking snippets with an image fallback. Some analytics and ad pixels include a <noscript><img ...></noscript> meant for the body, which ends up pasted into the head.
  • Tag manager's noscript iframe. Tag manager installation instructions place an iframe fallback right after the opening <body> tag. Paste it into the head, or into a theme field that outputs in the head, and it becomes an invalid element.
  • Plugins and theme settings that output a tracking image, a verification badge or a chat widget's markup in the head.
  • Stray text or broken markup, such as an unclosed tag or plain text from a bad template edit. Browsers' parsers end the head when they meet content that doesn't belong there, which has the same effect.

Symptoms

  • URL Inspection in Search Console shows Google selected a different canonical from the one you declared.
  • A page with noindex keeps appearing in results.
  • hreflang alternates are reported as missing.
  • Social previews ignore your Open Graph tags, because other crawlers parse heads similarly.
  • The tags are definitely in your source, which makes it confusing.

How to check a page

  1. Look at the rendered HTML, not only your template. Use Search Console's URL Inspection, or your browser's developer tools, to see the head as parsed. In developer tools, if elements you put in the head appear inside the body instead, the head ended early.
  2. View the raw source and read the head from top to bottom. Note anything that isn't one of the eight valid elements.
  3. Run the page through an HTML validator, such as the W3C's Nu Html Checker, which flags elements not allowed in the head and stray content.
  4. Check the order. Where are your canonical, robots meta and hreflang tags relative to third-party snippets? Anything placed after a questionable element is at risk.
  5. Compare templates. If only some page types are affected, such as product pages but not blog posts, compare their head output; the difference usually points to a plugin or template block.

How to fix it

  • Move body-only snippets to the body. The noscript iframe from your tag manager belongs immediately after <body>. Image pixel fallbacks belong in the body too.
  • Use the right field in your CMS. Many themes and plugins have separate "header scripts" and "body scripts" fields. Put each snippet where its instructions say.
  • Put SEO tags first. Place title, meta description, robots, canonical and hreflang near the top of the head, before third-party scripts. That way, even if something goes wrong later, the important tags are read first.
  • Remove snippets nobody uses. Old verification images and abandoned pixels are frequent offenders.
  • Fix broken markup in templates, such as unclosed tags or stray text.

After fixing, use URL Inspection to request a fresh crawl of important pages and check the rendered head again.

Single-page apps and frameworks

Sites built with JavaScript frameworks often manage the head with a library that adds and replaces tags as people navigate. Two things to check:

  • The initial HTML sent by the server should already contain the right title, canonical and robots tags for that URL, rather than adding them only after scripts run.
  • Duplicates. A framework may add a second canonical or robots tag without removing the template's original. Conflicting tags give Google a choice you didn't intend. There should be exactly one of each.

Server-side rendering or pre-rendering makes both easier to get right, because the head is complete before any script runs.

Prevent it coming back

  • Add a quick automated check to your deployment or a scheduled crawl: fetch key pages and fail if anything other than the valid elements appears in the head, or if the canonical is missing.
  • Keep a list of third-party snippets, where each one is installed, and who owns it.
  • Recheck after installing any plugin, app or tracking code.

A worked example

An illustrative Queenstown outdoor tours company noticed Google showing old booking URLs instead of the canonical tour pages. The canonical tags were in the template, but the rendered head showed an ad platform's <noscript><img> fallback pasted into the theme's header field, sitting above the canonical tags. Moving the snippet to the body field, and reordering the head so SEO tags came first, fixed it. URL Inspection then showed Google using the declared canonicals.

FAQ

Is <noscript> itself invalid in the head?

No, noscript is allowed. The problem is an img or iframe inside it in the head.

Do other search engines behave the same way?

Many crawlers and social platforms parse heads similarly, so valid markup helps everywhere.

Can JavaScript-added tags be affected?

Google renders pages, but keep critical tags in the initial HTML, early in the head.

Will one validation warning hurt rankings?

Not generally. The specific risk is elements that end the head early.

If Google seems to ignore tags you know are there, send us a page URL and we'll check what's breaking the head.

Sources

WhatsAppBook a call