Skip to content

Generate link rel=canonical #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Fil opened this issue Nov 15, 2023 · 1 comment
Open

Generate link rel=canonical #179

Fil opened this issue Nov 15, 2023 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@Fil
Copy link
Contributor

Fil commented Nov 15, 2023

With the host and origin options provided (#180, #42), we can derive the page’s canonical URL (which is a good thing to have on static websites that might be served under different circumstances). Maybe a good idea in that case to automatically add the corresponding link[rel=canonical].

To determine this URL we also need to know the page’s path; this can be done if head is a function that receives the path as an argument (see #1161).

@mbostock
Copy link
Member

Can you add more detail to the issue description, please? What does this mean? You can already add

<link rel="canonical" href="https://example.com/whatever/">

to any page.

I see three things possible interpretations here:

  1. Adding generic tags to the config.ts that are automatically added to every rendered page; VitePress does this with the head option; but if the value of the href value needs to vary for every page, then this won’t work
  2. Adding generic tags to the YAML front matter; VitePress does this with the head option (see Plot for example); but I don’t really see how this is preferable to just adding the link element to the page directly, as it’s just nonstandard equivalent to HTML
  3. Adding link rel=canonical tags specifically, dependent on providing a host in conjunction with base; VitePress uses sitemap.hostname for a sitemap, but they don’t automatically generate a link rel=canonical for every page

And an alternative or complement to (1) would be a more generic templating system.

@mbostock mbostock added this to the Future milestone Nov 15, 2023
@mbostock mbostock changed the title support rel-canonical Generate link rel=canonical Nov 15, 2023
@mbostock mbostock added the question Further information is requested label Nov 15, 2023
@mbostock mbostock removed this from the Future milestone Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants