-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Themes: Add a canonical_url option #4193
Conversation
A canonical url will let search engines know they should give higher ranking to latest version of the docs. The url points to the root of the documentation and requires a trailing slash.
doc/theming.rst
Outdated
they should give higher ranking to latest version of the docs. The url | ||
points to the root of the documentation and requires a trailing slash. | ||
|
||
.. cronical url: https://en.wikipedia.org/wiki/Canonical_link_element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you build this document ever? A hyperlink target should start with underscore. And this also has a typo. Please check them please.
BTW, I prefer to use RFC 6596 instead. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have a strong preference either way, but I think using the RFC 6596 link could be too technical for some.
@@ -116,6 +116,12 @@ These themes are: | |||
|
|||
- **sidebarwidth** (an integer): Width of the sidebar in pixels. (Do not | |||
include ``px`` in the value.) Defaults to 230 pixels. | |||
|
|||
- **canonical_url** (sting): A `canonical url`_ to let search engines know |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about canonical_baseurl
instead? I believe this is a part of URL, So baseurl
is better for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason that I used canonica_urll
is that a couple 3rd party themes already have this feature and use that variable instead so it will be easier for them to preserve compatibility without having to leave there own variable in their theme.
@@ -7,3 +7,4 @@ pygments_style = none | |||
nosidebar = false | |||
sidebarwidth = 230 | |||
navigation_with_keys = False | |||
canonical_url = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you wan to this as an option of HTML themes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apposed to adding it to the HTML builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for late response. Yes, I meant that. I think the responsibility of HTML theme is look and feel, and canonical URL is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will look into that.
sphinx/themes/basic/layout.html
Outdated
@@ -139,6 +139,9 @@ | |||
{%- block scripts %} | |||
{{- script() }} | |||
{%- endblock %} | |||
{%- if theme_canonical_url %} | |||
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change the suffix of the HTML files through html_file_suffix
. So we have to use variable to represent the name of file extension.
Poke |
FYI. The code freeze day of 1.7 will come in a week.
|
I just made an alternative of this. Please check #5049 :-) |
Merged #5049 instead. |
Subject: Provide better SEO for themes
Feature or Bugfix
Purpose
A canonical url will let search engines know they should give higher ranking to latest version of the docs. The url points to the root of the documentation and requires a trailing slash.