readthedocs / readthedocs.org

The source code that powers readthedocs.org
https://readthedocs.org/
MIT License
8.04k stars 3.58k forks source link

Automate documentation language indexing #4230

Closed agjohnson closed 5 years ago

agjohnson commented 6 years ago

For projects that have translations, if the document is not fully translated, Google can display results for the base language untranslated strings in a translated version. We can address this with a sitemap, and we can also address this with meta tags: https://support.google.com/webmasters/answer/189077

The implementation of this might be difficult though:

For example, a layout.html override would approximate this, only using context data with a list of translations:

{% extends "!layout.html" %}
{% block linktags %}
    <link rel="alternate" hreflang="en" href="http://docs.godotengine.org/en" />
    <link rel="alternate" hreflang="de" href="http://docs.godotengine.org/de" />
    <link rel="alternate" hreflang="es" href="http://docs.godotengine.org/es" />
    <link rel="alternate" hreflang="fr" href="http://docs.godotengine.org/fr" />
    <link rel="alternate" hreflang="ko" href="http://docs.godotengine.org/ko" />
    <link rel="alternate" hreflang="pl" href="http://docs.godotengine.org/pl" />
    <link rel="alternate" hreflang="pt-br" href="http://docs.godotengine.org/pt-br" />
    <link rel="alternate" hreflang="uk" href="http://docs.godotengine.org/uk" />
    <link rel="alternate" hreflang="zh-cn" href="http://docs.godotengine.org/zh-cn" />
    {{ super() }}
{% endblock %}

A template override could work for the majority of projects, and only themes that remove the standard linktags block would not get the automated language feature.

humitos commented 5 years ago

This issue is related to the generation of the sitemap: #557

stsewd commented 5 years ago

We can address this with a sitemap, and we can also address this with meta tags

We already have this with sitemap. Closing