SEO Management
The SEO tags in your project should be included in the following files:
src/app/[commerce]/[locale]/[currency]/layout.tsx
src/app/[commerce]/[locale]/[currency]/(root)/category/[pk]/page.tsx
src/app/[commerce]/[locale]/[currency]/(root)/list/page.tsx
src/app/[commerce]/[locale]/[currency]/(root)/product/[pk]/page.tsx
src/app/[commerce]/[locale]/[currency]/(root)/special-page/[pk]/page.tsx
src/app/[commerce]/[locale]/[currency]/(root)/group-product/[pk]/page.tsx
If your project has a category landing page, you also need to edit the SEO tags for the category landing page created within the root.
src/app/[commerce]/[locale]/[currency]/(root)/categoryLandigPage/page.tsx
To create metadata, first import the existing Metadata in Next.js:
An async function named generateMetadata is created. This function runs before the function root and puts metadata in head.
The params
and searchParams
parameters, as well as the props
you want to display in the metadata, can be added to the generateMetadata function.
Examples of generateMetadata function with different parameter options:
Without parameters:
With parameters:
With parameters and props:
<{ pk: number }>
represents a single attribute to be extracted from props.
SEO data such as title, description, canonical, openGraph can also be added to metadata.
Example Metadata variable:
Example of the generateMetadata function for src/app/[commerce]/[locale]/[currency]/(root)/product/[pk]/page.tsx
:
Last updated
Was this helpful?