Appease our great search engine overlords

This hopefully fixes all translated pages showing up in search engine results, and makes the STABLE version of each page canonical.
In turn, this allows us to re-enable indexing of the version-specific pages (see robots.txt changes), as search engines should prefer the canonical (stable) version, and only show the other versions if no canonical (stable) version exists (i.e. because that feature is only in latest, or was removed in stable).

It adds proper canonical links for all generated pages, and fixes the existing links between the various translations of a page by both ensuring the pages links to itself with the proper language tag, and by properly linking to the full path of other translated versions.

(cherry picked from commits:
- fd5f6f4909,
- 263ff56251,
- e21df0671f,
- 24781e377b,
- 66d185d5d2,
- 3c79f3e321)

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
Max Hilbrunner
2020-05-04 09:37:21 +02:00
committed by Rémi Verschelde
co-authored by Rémi Verschelde
parent 7b5a66c678
commit e2e1aeac71
4 changed files with 53 additions and 9 deletions
+14
View File
@@ -0,0 +1,14 @@
{% extends "!layout.html" -%}
{% block linktags -%}
{% if godot_inject_language_links -%}
{% for alternate_lang in godot_docs_supported_languages -%}
{# Convert to ISO 639-1 format, e.g. zh_CN -> zh-cn -#}
{% set alternate_lang_href = alternate_lang.lower().replace("_", "-") -%}
<link rel="alternate" hreflang="{{ alternate_lang_href }}" href="{{ godot_docs_basepath }}{{ alternate_lang }}/{{ godot_canonical_version }}/{{ pagename }}{{ godot_docs_suffix }}" />
{% endfor -%}
<link rel="alternate" hreflang="x-default" href="{{ godot_docs_basepath }}{{ godot_default_lang }}/{{ godot_canonical_version }}/{{ pagename }}{{ godot_docs_suffix }}" />
<link rel="canonical" href="{{ godot_docs_basepath }}{{ lang_attr }}/{{ godot_canonical_version }}/{{ pagename }}{{ godot_docs_suffix }}" />
{% endif -%}
{{ super() }}
{% endblock -%}
@@ -95,8 +95,12 @@ You can help to translate the official Godot documentation on our `Hosted Weblat
:alt: Translation state
:align: center
:target: https://hosted.weblate.org/engage/godot-engine/?utm_source=widget
:width: 287
:height: 66
There also is the official `Godot I18N repository <https://github.com/godotengine/godot-docs-l10n>`_. where you can see when the data was last synced.
There also is the official
`Godot i18n repository <https://github.com/godotengine/godot-docs-l10n>`_
where you can see when the data was last synchronized.
License
-------
+34 -4
View File
@@ -38,7 +38,32 @@ version = os.getenv("READTHEDOCS_VERSION", "3.0")
# The full version, including alpha/beta/rc tags
release = version
language = "en"
# Language / i18n
supported_languages = {
"en": "Godot Engine (%s) documentation in English",
"de": "Godot Engine (%s) Dokumentation auf Deutsch",
"es": "Documentación de Godot Engine (%s) en español",
"fr": "Documentation de Godot Engine (%s) en français",
"fi": "Godot Engine (%s) dokumentaatio suomeksi",
"it": "Godot Engine (%s) documentazione in italiano",
"ja": "Godot Engine (%s)の日本語のドキュメント",
"ko": "Godot Engine (%s) 문서 (한국어)",
"pl": "Dokumentacja Godot Engine (%s) w języku polskim",
"pt_BR": "Documentação da Godot Engine (%s) em Português Brasileiro",
"ru": "Документация Godot Engine (%s) на русском языке",
"uk": "Документація до Godot Engine (%s) українською мовою",
"zh_CN": "Godot Engine (%s) 简体中文文档",
}
language = os.getenv("READTHEDOCS_LANGUAGE", "en")
if not language in supported_languages.keys():
print("Unknown language: " + language)
print("Supported languages: " + ", ".join(supported_languages.keys()))
print(
"The configured language is either wrong, or it should be added to supported_languages in conf.py. Falling back to 'en'."
)
language = "en"
exclude_patterns = ["_build"]
@@ -78,6 +103,8 @@ html_theme_options = {
# 'navigation_depth': 4, # Depth of the headers shown in the navigation bar
}
html_title = supported_languages[language] % version
# VCS options: https://docs.readthedocs.io/en/latest/vcs.html#github
html_context = {
"display_github": True, # Integrate GitHub
@@ -85,6 +112,12 @@ html_context = {
"github_repo": "godot-docs", # Repo name
"github_version": "master", # Version
"conf_py_path": "/", # Path in the checkout to the docs root
"godot_inject_language_links": True,
"godot_docs_supported_languages": list(supported_languages.keys()),
"godot_docs_basepath": "https://docs.godotengine.org/",
"godot_docs_suffix": ".html",
"godot_default_lang": "en",
"godot_canonical_version": "stable",
}
html_logo = "img/docs_logo.png"
@@ -123,6 +156,3 @@ linkcheck_timeout = 10
locale_dirs = ["../sphinx/po/"]
gettext_compact = False
# Exclude class reference when marked with tag i18n.
if tags.has("i18n"):
exclude_patterns = ["classes"]
-4
View File
@@ -1,7 +1,3 @@
user-agent: *
disallow: /*/3.2
disallow: /*/3.1
disallow: /*/3.0
disallow: /*/2.1
sitemap: https://docs.godotengine.org/sitemap.xml