Engineering

Every post on my blog was telling Google not to index it

20 August 2026, 6 minute read

I found it this morning by accident, while checking something else. Nine posts each carried a tag that says the page is a duplicate and a different page should be indexed instead. By the end of the afternoon I had found 14 pages across three sections with the same tag.

I wrote that tag once, in a file that has nothing to do with any individual post.

The line that caused it

In app/blog/layout.tsx:

export const metadata: Metadata = {
  title: "Writing",
  alternates: { canonical: "/blog" },   //  <- this
};

That looks correct, because the blog index's canonical URL is /blog.

In the Next.js App Router, a layout wraps its own page and every route nested underneath it, and metadata is inherited. So app/blog/layout.tsx wraps /blog, /blog/first-post, /blog/second-post, all of them, and hands every single one a canonical of /blog.

On every post, that renders as:

<link rel="canonical" href="https://purcellventures.co/blog"/>

What does that tell a search engine?

A canonical tag tells a search engine that this page and the target page are the same content, and that the target is the one to keep. Google treats it as a strong signal. Google's documentation on consolidating duplicate URLs describes this consolidation behaviour.

When a post says its canonical is the index, Google reads it as: this post is a duplicate of the listing page. So it consolidates the two, keeps the index, and drops the post. It shows no error or warning, because it is following the tag.

Google dropped the author markup, structured data and titles on those pages along with them, even though all of it was correct.

Why does the bug go unnoticed?

I found three reasons.

It looks right in the file. Every reviewer who opens that layout sees a canonical pointing at the page the file is named after, and the bug is in the inheritance.

Nothing fails. The build passes, the pages render and the links work. There is no error state, because the site is doing what it was configured to do.

The only symptom is missing search results. Pages never show up in search, and on a new site that is easy to blame on the site being new.

How do I check my own site in two minutes?

One command:

curl -sL https://yoursite.com/blog/some-post | grep canonical

If the href is anything other than the URL you requested, that page points at a different URL. Check three or four pages from different sections. Section index pages are the usual culprits, so try a product page under a category and a post under a blog.

I found the same bug in two more places on my own site the same afternoon: three course pages canonicalising to /courses, and two pages canonicalising to /digital. That made fourteen pages in total, all caused by layout inheritance, and the blog was where I noticed it first.

The fix that failed and the fix that worked

The obvious fix is to move the canonical from the layout onto the index page itself. That failed for me: app/blog/page.tsx is a client component, and client components cannot export metadata. That is probably how it ended up in the layout to begin with.

The fix that works is to delete the canonical from the layout. A page with no canonical tag self-canonicalises: the engine treats the URL it fetched as the canonical one. That is the right answer for the index and the right answer for every post.

Then give each post its own, explicitly:

// app/blog/my-post/page.tsx
export const metadata = {
  title: "My post",
  alternates: { canonical: "/blog/my-post" },
};

For posts that are client components and cannot export metadata, add a layout.tsx beside the page that does nothing but carry the canonical and render its children.

Testing for this kind of bug

This is the third bug of this kind I have hit this year. In each one, a setting made once and inherited widely failed without an error.

Tests that check the delivered output catch these bugs, and tests that only check whether an error was thrown miss them. A test that fetches four live pages and checks each one canonicalises to itself would have caught this the day it shipped, and it is eight lines.

Part of the guide AI websites and getting found by AI search.