question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
slorbercommented, Aug 10, 2021

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/5330

I 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:

---
id: my-doc-id
---

<head>
    <link rel="canonical" href="http://mysite.com/example" />
</head>

# Markdown title

Some markdown text

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 the children would be created from the Yaml. But first I’d like to know if you feel limited with this approach.

0reactions
a-parsercommented, May 18, 2021

Any updates on this issue? It’s documented here: https://docusaurus.io/docs/docusaurus-core#head but totally doesn’t work

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supercharge Your Site's SEO With Canonical URLs
The value of a canonical URL for SEO lies in the control it gives you over what content from your website is visible...
Read more >
What is a Canonical URL? Best Practice Guide 2022 - Shopify
Canonical URLs play a critical role in ensuring that your client's website isn't penalized by search engines and that the SEO is strong....
Read more >
URL Canonicalization and the Canonical Tag | Documentation
A canonical URL is the URL of the page that Google thinks is most representative from a set of duplicate pages on your...
Read more >
Rel=canonical: the ultimate guide - Yoast
A canonical URL lets you tell search engines that certain similar URLs are actually the same. Because sometimes you have products or content ......
Read more >
Canonical URLs – Best Practices, Common Mistakes & Their ...
Quick answer: Canonical tags affect SEO from two points of view. For once, they directly influence how search results display. They can also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found