Category: Next.js, React and TypeScript

Next.js: two titles and an erroneous canonical after migration to Metadata API

Read this guide in Polish

HTML contains a double title or canonical, because part of metadata generates App Router, and part of the old Head component. Inconclusive metadata can come from the parallel use of new and old head management.

How to determine the source of the error

In HTML page check the number of title items, canonical link and metadata description.

View layout.tsx, page.tsx, generateMetadata and any manual header tags in components.

What to do step by step

1. Move metadata to one Metadata API based source and provide metadataBase for relative addresses.

2 . Unify the inheritance of metadata between layout and page, openly defining the title of the subpage and canonical.

How to check the score

There is one correct title in HTML and canonical indicating the proper production URL.

What to do

Do not set every subpage of the canonical home page, making it difficult to index specific content.