Next JS producing invalid canonical meta tags in Next JS (according to Lighthouse)
See original GitHub issueBug report
Describe the bug
Using AMP in next seems to be producing invalid canonical meta tags (at least, according to Google Lighthouse).
I’ve been working on an AMP app using Next JS, and have been improving performance and SEO with Google Lighthouse. Tonight I noticed a new alert (or maybe it was an old alert and I just now noticed it) at this URL: https://anything-grown-beta.nelsonwebdev.com/market/hibbing-farmers-market
If you go to that URL and run an audit, you’ll see I get dinged for SEO:
I tried putting my own metatag on the page, with an absolute path (I don’t know exactly that that’s what Google wants but I just wanted to see, and based it off this doc: https://developers.google.com/web/tools/lighthouse/audits/canonical).
However, as you can probably guess, when I tried to put my own metatag on the page, Next JS got grumpy, albeit it did point me to this doc:
https://github.com/zeit/next.js/blob/master/errors/conflicting-amp-tag.md
What’s the solution here? I really want to use AMP in Next JS (because it’s awesome), but SEO is obviously a very high concern of mine.
Oh – I’m on the latest canary, too. 8.1.1-canary.24
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
For others, this issue is only related to AMP mode and when not using AMP we don’t add a canonical link
It looks like Google no longer accepts relative canonical links as this does appear to be the reason in lighthouse as seen here, good catch! I submitted a PR here that will allow configuring the canonical to have an absolute URL.