feat(SW-1885): Added noindex/nofollow to pages with searchparams when generating metadata to avoid duplicate content issues

Approved-by: Linus Flood
This commit is contained in:
Erik Tiekstra
2025-03-17 13:15:13 +00:00
parent e530905d8d
commit 05addfa0bb
4 changed files with 56 additions and 50 deletions
+5 -1
View File
@@ -13,10 +13,14 @@ export async function generateMetadata({
LangParams & ContentTypeParams & UIDParams,
{ subpage?: string; filterFromUrl?: string }
>) {
const { subpage, filterFromUrl } = searchParams
const { subpage, filterFromUrl, ...otherSearchParams } = searchParams
// If there are other (real) search params, we don't want to index the page as this will
// cause duplicate content issues.
const noIndexOnSearchParams = !!Object.keys(otherSearchParams).length
const metadata = await serverClient().contentstack.metadata.get({
subpage,
filterFromUrl,
noIndex: noIndexOnSearchParams,
})
return metadata
}