When re-publishing content written for a company blog on my personal blog, I need to add a canonical link to the original version published on the company page to avoid duplicate content issues in search engines.
Sphinx adds canonical link relations to the <head> element by configuring html_baseurl. However, this value is configured once for the entire blog and relies on the URL scheme of the pages generated by Sphinx, so this approach is not flexible enough to link individual posts to arbitrary URLs.
Proposed solution
As a solution, we could add a canonical_link option to the post directive, which overwrites the default canonical link (pageurl).
Describe the feature
When re-publishing content written for a company blog on my personal blog, I need to add a canonical link to the original version published on the company page to avoid duplicate content issues in search engines.
Sphinx adds canonical link relations to the
<head>
element by configuringhtml_baseurl
. However, this value is configured once for the entire blog and relies on the URL scheme of the pages generated by Sphinx, so this approach is not flexible enough to link individual posts to arbitrary URLs.Proposed solution
As a solution, we could add a
canonical_link
option to thepost
directive, which overwrites the default canonical link (pageurl
).