Skip to content

Commit d5b802f

Browse files
authored
docs: Add canonical link to html pages (#314)
* Add _templates/page.html with extrahead block containing canonical link * Add templates_path to conf.py
1 parent f0d3eac commit d5b802f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

docs/source/_templates/page.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{#
2+
Adds a canonical link to the stable version of the documentation to each built hmtl page.
3+
The reason to do that is that search engines require it:
4+
https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls
5+
6+
This template overrides the page.html furo template
7+
(https://github.com/pradyunsg/furo/blob/main/src/furo/theme/furo/page.html) by adding an extra
8+
line to its <head> section, with the appropriate canonical link. Note that there is no guarantee
9+
that the furo theme keeps using a file named page.html, so this could silently break with future
10+
updates of furo. See https://pradyunsg.me/furo/customisation/injecting/ and
11+
https://github.com/pradyunsg/furo/discussions/248 for more information.
12+
#}
13+
{% extends "!page.html" %}
14+
{% block extrahead %}
15+
<link rel="canonical" href="https://torchjd.org/stable/{{ pagename }}.html">
16+
{% endblock %}

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
html_theme = "furo"
4646
html_static_path = ["_static"]
47+
templates_path = ["_templates"]
4748

4849
autodoc_member_order = "bysource"
4950
intersphinx_mapping = {

0 commit comments

Comments
 (0)