Improvement (v2): Allow authors to define a canonical URL to help with SEO
See original GitHub issue🚀 Feature
Allow users to define an optional canonical URL per doc item.
Have you read the Contributing Guidelines on issues?
Yes
Motivation
Allowing users to define a canonical URL will greatly help with pointing search engines into the right direction, especially when multiple versions of the same doc item exist.
Pitch
As mentioned in the motivation, allowing users to define a canonical URL will greatly help with efforts regarding SEO. Not only will this ensure that search engines know what version of a particular doc item is most relevant, it will also ensure that other versions of the same doc item are known and are pointing to the most relevant / newest version. Also see https://yoast.com/rel-canonical/ for more information.
How this feature could work, is by adding an additional (optional) Markdown property that can defined in the header of the particular doc item. This property can then be used and outputted in the HTML as a <link rel="canonical" href="https://example.com/mydocitem/" />
.
If this property is omitted from the header, it should still be outputted in the resulting HTML, but must point to itself.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
Hey
I’m adding support for using
<head>
in md files as a shortcut to the Docusaurus<Head>
component in PR https://github.com/facebook/docusaurus/pull/5330I prefer this solution based on
<Head>
because it is more flexible than yaml and cover various use-cases at once, including adding html/body attributes, and can even support evaluating the metadata at runtime thanks to MDX.This will now work:
We may add frontmatter later: it can be useful if we support another parser than MDX, but in the end it will still remain based on
<Head>
, just thechildren
would be created from the Yaml. But first I’d like to know if you feel limited with this approach.Any updates on this issue? It’s documented here: https://docusaurus.io/docs/docusaurus-core#head but totally doesn’t work