Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Title, meta or canonical changed by JavaScript: how to fix it

SEO-140Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

Every page has two versions. The raw HTML is what the server sends before any script runs. The rendered HTML is what the page looks like after the browser (or Google's renderer) has run the JavaScript. This issue is when the <title>, <meta name="description">, <link rel="canonical"> or <meta name="robots"> differ between the two.

Raw HTML vs rendered HTML

Conflicting

  • Raw HTML canonical points to /product/
  • JS rewrites canonical to /product/?variant=2
  • Title changes from 'Blue Shoes | Shop' to 'Loading...' then to a new text
  • Crawlers that skip JS and Google disagree

Consistent

  • Canonical, title and description set in the server HTML
  • JS does not touch them, or sets the same value
  • Only one canonical tag on the page
  • Every crawler sees the same signals

Why it costs you leads or sales

How a conflicting canonical loses traffic
  1. Server sends HTMLCanonical points to the clean URL
  2. JS runsScript rewrites canonical to a parameter URL
  3. Google choosesConflicting signals, may index the wrong URL
  4. Search listingWrong URL or weak snippet shown

The break happens after the server response, so it is easy to miss in a normal browser check.

How to check if your site has it

Compare raw and rendered HTML
  1. View the raw HTML

    Open the page in Chrome, press Ctrl+U (Cmd+Option+U on Mac) or go to view-source:. Search for <title, description and canonical. Note the values.

  2. View the rendered HTML

    Open DevTools (F12), go to Elements and search the <head> for the same tags. Note the values and how many canonical tags there are.

  3. Use Google's view

    In Google Search Console, use URL Inspection, then View crawled page (HTML) or Test live URL, and compare the head with your raw source.

  4. Fetch without JavaScript

    Run curl -s https://example.com/page | grep -iE '<title|canonical|name="description"|name="robots"' and compare it with DevTools.

  5. Crawl at scale

    Tools such as Screaming Frog (JavaScript rendering mode) can crawl your site and report where the raw and rendered titles, descriptions or canonicals differ.

Quick raw HTML checkbash
curl -s -A "Mozilla/5.0" https://example.com/page | grep -iE '<title|rel="canonical"|name="description"|name="robots"'
Run in the DevTools console to see rendered valuesjavascript
console.log({
  title: document.title,
  canonicals: [...document.querySelectorAll('link[rel=canonical]')].map(l => l.href),
  description: document.querySelector('meta[name=description]')?.content,
  robots: document.querySelector('meta[name=robots]')?.content
});

How to fix it

Fix by platform
  1. Use one SEO source

    Run only one of Yoast, Rank Math or similar. Two plugins, or a plugin plus a theme, often output duplicate canonicals.

  2. Remove theme or script overrides

    Search the theme and plugins for scripts that edit document.title or canonical links, and remove them or make them output the same value.

  3. Clear caches

    Purge page cache and CDN so the raw HTML reflects the fixed settings.

Target: one set of tags in the server HTMLhtml
<head>
  <title>Blue Running Shoes | Example Store</title>
  <meta name="description" content="Lightweight blue running shoes with free returns.">
  <link rel="canonical" href="https://example.com/product/blue-running-shoes/">
</head>

How to confirm it's fixed

Confirmation checks
  • Raw HTML (view-source or curl) shows the correct title, description and canonical
  • Rendered HTML in DevTools shows the same values
  • Only one canonical tag exists in the rendered head
  • Search Console URL Inspection shows the right canonical and head
  • A crawler with JavaScript rendering reports no raw vs rendered differences
  • Page cache and CDN were purged before testing

How to prevent it happening again

Prevention habits
  • Keep SEO tags in one place: the CMS, plugin or framework head manager
  • Do not manage titles or canonicals through a tag manager
  • Add a raw vs rendered comparison to your release checklist
  • Re-crawl with JavaScript rendering after theme, plugin or app changes
  • Review A/B testing tools so they do not change canonicals or robots
  • Watch Search Console for 'Duplicate, Google chose different canonical than user' under Page indexing

How FunnelGuard handles this

Questions people ask

Does Google use the canonical from raw HTML or after JavaScript?

Google can use both. It reads the raw HTML first and may read the canonical again after rendering. If they differ, it has to choose, which can result in the wrong URL being indexed. Keep them identical.

Why is my page title different in Google than in my browser?

Google may have used the raw HTML title, or rewritten the title itself because it was vague, too long or changed by JavaScript. Check view-source against DevTools. If they differ, align them.

How do I compare raw HTML and rendered HTML?

Open view-source: for the raw HTML and the DevTools Elements panel for the rendered version, then compare the title, meta description, canonical and robots tags. Search Console URL Inspection also shows what Google saw.

Can JavaScript set a canonical tag?

Yes, Google can process a canonical added by JavaScript, but it is less reliable than one in the raw HTML. Many other crawlers ignore it. Set it on the server whenever you can.

Why do I have two canonical tags on my page?

Usually a plugin, theme, app or script adds one on top of an existing one. Google may ignore both when they conflict. Remove the extra source so only one canonical tag remains.

Do AI crawlers see JavaScript-changed titles?

Many do not run JavaScript, so they only read the raw HTML title and description. If your real title appears only after scripts run, they may quote a placeholder.

Does FunnelGuard detect changed titles or canonicals?

No. FunnelGuard does not check this yet. It monitors journeys, tracking and lead delivery, so use a rendering crawler and Search Console for title and canonical differences.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.