Is it possible to add docs versions to page titles? #10362
-
I assume that duplicate page titles and meta descriptions could cause SEO problems and thus lower positions in search results. Can I add the version of the docs to page titles and meta descriptions to eliminate duplication? e.g. instead of a duplicate name: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Regarding the SEO issue, this has been discussed a bit here: #9049 Unfortunately afaik there's no way to tell Google about almost duplicate pages due to docs versioning. I'm not sure it's a big deal in practice and even former Angular docs (<= v17) had duplicates: Regarding using different titles per version, you can achieve that by swizzling Here's an example implementation: import React from 'react';
import {PageMetadata} from '@docusaurus/theme-common';
import {useDoc, useDocsVersion} from '@docusaurus/plugin-content-docs/client';
export default function DocItemMetadata(): JSX.Element {
const {version} = useDocsVersion();
const {metadata, frontMatter, assets} = useDoc();
const myVersionedTitle = `${version} - ${metadata.title}`;
return (
<PageMetadata
title={myVersionedTitle}
description={metadata.description}
keywords={frontMatter.keywords}
image={assets.image ?? frontMatter.image}
/>
);
} (Note, in v3.4 the import is likely to be |
Beta Was this translation helpful? Give feedback.
Regarding the SEO issue, this has been discussed a bit here: #9049
Unfortunately afaik there's no way to tell Google about almost duplicate pages due to docs versioning. I'm not sure it's a big deal in practice and even former Angular docs (<= v17) had duplicates:
Regarding using different titles per version, you can achieve that by swizzling
@theme/DocItem/Metadata
and altering the metadata we put in the page for each docs.Here's an example implementation: