← Back to the full checklist

Your canonical tag points at a URL that redirects

DISCOVERY · SEO

Search Console reports pages as Alternate page with proper canonical tag, or shows the canonical resolving somewhere other than where you expected. Pages that should be indexed are not.

The usual cause is small and easy to miss: the canonical URL is written with a file extension, while the live URL has none.

What it looks like

Your file on disk is anagram-solver.html. Your host serves it at /anagram-solver and issues a 308 redirect from the .html version. Meanwhile the page says:

<link rel="canonical" href="https://yourdomain.com/anagram-solver.html" />

You have told search engines that the authoritative address of this page is a URL that immediately redirects to a different one. That is a contradiction, and crawlers resolve contradictions conservatively.

Find every instance

Extract the canonicals and check what each one actually returns:

for f in *.html; do
  u=$(grep -o 'rel="canonical" href="[^"]*"' "$f" | sed 's/.*href="//; s/"//')
  [ -n "$u" ] && echo "$f -> $(curl -s -o /dev/null -w '%{http_code}' "$u") $u"
done

Anything not returning 200 is misdeclared. A 301 or 308 here is a defect, not a redirect working correctly.

Fix all four places, not just the canonical

The same wrong URL is almost always duplicated. Fixing only the canonical leaves the rest contradicting it:

  1. <link rel="canonical">
  2. <meta property="og:url">
  3. The <loc> entry in sitemap.xml
  4. Internal links in your own navigation, which should point at the final URL rather than relying on a redirect
sed -i 's#href="https://yourdomain.com/page.html"#href="https://yourdomain.com/page"#g;
        s#content="https://yourdomain.com/page.html"#content="https://yourdomain.com/page"#g' page.html

One thing that is not a bug

"Page with redirect" appearing in Search Console for your http:// URLs is expected and correct. Those redirect to https:// because they should. Do not go hunting for a problem there. Only worry when a canonical target redirects.

Add this to your pre-launch check. Canonical, og:url and sitemap all resolving to a 200, on every page, before you submit anything to a search engine or an ad network. It takes one loop and catches a class of defect that is otherwise invisible until indexing quietly underperforms for weeks.

Related