Google Search Console - "amp-story canonical error" causing Web Story to be invalid #199472
Replies: 3 comments
-
|
This error has a precise, well-documented cause, and your specific tech stack (Next.js/React generating the page dynamically) is the most common source of it. 1. What exactly causes an
|
Beta Was this translation helpful? Give feedback.
-
1. What causes the "amp-story canonical error"?In a standard AMP setup, the AMP Stories must be standalone documents. According to this rule, the canonical URL of an AMP Story page must point directly to itself (self-canonical). If your page points to a different article page that embeds the story instead of pointing to itself, Google flags this as an "amp-story canonical error". This is not a bug; it is a current and intentional requirement of the AMP platform. 2. Where should the Canonical URL point?It must point exactly to the story itself.
3. How should the Canonical tag look?The tag in your story's code must look exactly like this: <!-- Assuming the URL is: https://yourdomain.com/stories/my-story -->
<link rel="canonical" href="https://yourdomain.com/stories/my-story">There is a crucial rule here: The value inside the
4. Why is this common in Next.js / React Apps and how to fix it?In dynamically generated sites (like Next.js), this mismatch usually happens for 4 main reasons: A. Incorrect or Hardcoded Canonical URL CalculationIf you pull the canonical URL from environment variables (e.g., Pages Router Example: import Head from 'next/head';
import { useRouter } from 'next/router';
export default function StoryPage() {
const router = useRouter();
// Strip query parameters to get the exact matching base URL
const canonicalUrl = `https://yourdomain.com${router.asPath.split('?')[0]}`;
return (
<>
<Head>
<link rel="canonical" href={canonicalUrl} />
</Head>
{/* AMP story code */}
</>
);
}App Router Example (using export async function generateMetadata({ params }) {
return {
alternates: {
canonical: `https://yourdomain.com/stories/${params.slug}`,
},
};
}B. Trailing Slash MismatchIf C. Hydration Delay (Client-Side Rendering)If your canonical tag is injected into the page after it loads via React's D. Dynamic Routes Generating Multiple URLsIf a story can be accessed with case variations ( How to verify your fix?
|
Beta Was this translation helpful? Give feedback.
-
|
The amp-story canonical error occurs when the canonical URL in your AMP Web Story is missing, incorrect, redirects, or does not match the actual story URL. For a standalone AMP Web Story, the canonical tag should point to the story itself: Do not point the canonical URL to a separate article page unless the story is merely an AMP version of that article. In Next.js/React applications, this error is commonly caused by dynamically generated canonical tags that do not exactly match the final public URL. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Discussion Type
Question
Discussion Content
Hi everyone,
I'm having an issue with my AMP Web Stories in Google Search Console.
The URL Inspection report shows:
Google says the story won't appear in Search results because of this issue.
Details:
I'm trying to understand:
Current Search Console Message:
Web Story is invalid
amp-story canonical error
Any guidance or examples of a correct canonical setup would be greatly appreciated.
Thanks!

Beta Was this translation helpful? Give feedback.
All reactions