Adding "View Python 3 Documentation" to all Python 2 documentation URLs

Right now, many Google searches for Python modules return the Python 2 documentation. IMO since 2 will be reaching EOL in around 3 years, it would be nice to have a giant red box at the top with a link to the Python 3 documentation. SFML already does something like this: https://www.sfml-dev.org/tutorials/2.3/ (I mean, it would be even nicer to have a "jump to latest version" for *all* not-new Python versions, though I figured just 2 would be a lot easier.) -- Ryan (ライアン) Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else http://refi64.com/

Another example is PyPI showing a bold "Latest version: x.x.x". Example: https://pypi.python.org/pypi/requests/2.17.0 Victor 2017-09-07 0:52 GMT+02:00 Ryan Gonzalez <rymg19@gmail.com>:

That's a good idea. Could you suggest it to https://github.com/python/pythondotorg/ ? (There is actually a version switcher on every page, but it's rather polite. :-) On Wed, Sep 6, 2017 at 3:52 PM, Ryan Gonzalez <rymg19@gmail.com> wrote:
-- --Guido van Rossum (python.org/~guido)

A progmatic workaround for yourself: https://addons.mozilla.org/de/firefox/addon/py3direct/ https://chrome.google.com/webstore/detail/py3redirect/codfjigcljdnlklcaopdci... Bar Harel <bzvi7919@gmail.com> schrieb am Do., 7. Sep. 2017 um 07:52 Uhr:

A sitemap.xml may be helpful for indicating search relevance to search crawlers? https://www.google.com/search?q=sphinx+sitemap On Thursday, September 7, 2017, Bar Harel <bzvi7919@gmail.com> wrote:

On Thu, Sep 07, 2017 at 05:51:31AM +0000, Bar Harel wrote:
A bit radical but do you believe we can contact Google to alter the search results?
You should try DuckDuckGo, it recognises "python" searches and quotes from, and links to, the Python 3 documentation at the top of the page before the search results. E.g.: https://duckduckgo.com/html/?q=python%20functools Both Bing and Yahoo also gives the Python 2 docs first: https://www.bing.com/search?q=python+functools https://au.search.yahoo.com/search?p=python+functools -- Steve

Guido van Rossum <guido@python.org> wrote:
We just need someone with SEO experience to fix this for us.
I'm not an SEO expert, but I think a possible approach would be using (or partly abusing) the <link rel="canonical"> element on the documentation pages: https://support.google.com/webmasters/answer/139066 Python's documentation is already using these canonical links, just in an incomplete way: The Python documentation for 2.7 and 3.5 and later has a <link rel="canonical"> pointing to the generic documentation URL of the same major Python version, e.g. in https://docs.python.org/3/library/functools.html you can find this in the page source: <link rel="canonical" href="https://docs.python.org/3/library/functools.html" /> This is why if you search for "python 3 $module" in Google, you'll never see a direct link to the 3.5 or 3.6 versions of the documentation (because Google merges them with the generic docs.python.org/3/), but you still results for versions 3.2, 3.3 etc. of the documentation (because the lack the canonical links). A very good step would be to also add this canoncial link to the documentation versions 3.0-3.4, this will make docs.python.org/3.3/ etc. vanish from Google and probably rank the generic docs.python.org/3/ higher than now. And now to the abuse part (I'm honestly not sure how well this would actually work): If you would add such a canonical link in docs.python.org/2/ pointing to docs.python.org/3/ (at least where the same module exists in both versions), you would eventually hide /2/ from the search results. If you don't want to be so extreme (people still want Python 2 documentation if they search for "python 2 $module") you could remove the canonical link just from the specific docs.python.org/2.7/ which will then be ranked much lower than docs.python.org/3/ in the search results, but at least still show up. Sebastian

Sebastian Krause <sebastian@realpath.org> wrote:
Here is Nick Coghlan's bpo issue which added these canonical links: https://bugs.python.org/issue26355 - looks like applying this to the older doc versions never happened in the end.

On 7 September 2017 at 12:24, Sebastian Krause <sebastian@realpath.org> wrote:
Right, as adding those will need to be handled through the web server and/or by manually regenerating the docs with the additional HTML headers - making the changes to the CPython repo won't achieve anything, since the docs for those branches aren't automatically regenerated anymore. Another big task that could be undertaken is to start re-routing unqualified deep links to Python 3 - the reason we still haven't done that is because the tree layout is actually different (as per the six.moves module), so it isn't a trivial rewrite rule the way the current redirection into the Python 2 docs is. Given such a mapping, it would also be possible to add the corresponding canonical URL entries to the Python 2.7 documentation to merge their search ranking in to the corresponding Python 3 pages. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia

Another example is PyPI showing a bold "Latest version: x.x.x". Example: https://pypi.python.org/pypi/requests/2.17.0 Victor 2017-09-07 0:52 GMT+02:00 Ryan Gonzalez <rymg19@gmail.com>:

That's a good idea. Could you suggest it to https://github.com/python/pythondotorg/ ? (There is actually a version switcher on every page, but it's rather polite. :-) On Wed, Sep 6, 2017 at 3:52 PM, Ryan Gonzalez <rymg19@gmail.com> wrote:
-- --Guido van Rossum (python.org/~guido)

A progmatic workaround for yourself: https://addons.mozilla.org/de/firefox/addon/py3direct/ https://chrome.google.com/webstore/detail/py3redirect/codfjigcljdnlklcaopdci... Bar Harel <bzvi7919@gmail.com> schrieb am Do., 7. Sep. 2017 um 07:52 Uhr:

A sitemap.xml may be helpful for indicating search relevance to search crawlers? https://www.google.com/search?q=sphinx+sitemap On Thursday, September 7, 2017, Bar Harel <bzvi7919@gmail.com> wrote:

On Thu, Sep 07, 2017 at 05:51:31AM +0000, Bar Harel wrote:
A bit radical but do you believe we can contact Google to alter the search results?
You should try DuckDuckGo, it recognises "python" searches and quotes from, and links to, the Python 3 documentation at the top of the page before the search results. E.g.: https://duckduckgo.com/html/?q=python%20functools Both Bing and Yahoo also gives the Python 2 docs first: https://www.bing.com/search?q=python+functools https://au.search.yahoo.com/search?p=python+functools -- Steve

Guido van Rossum <guido@python.org> wrote:
We just need someone with SEO experience to fix this for us.
I'm not an SEO expert, but I think a possible approach would be using (or partly abusing) the <link rel="canonical"> element on the documentation pages: https://support.google.com/webmasters/answer/139066 Python's documentation is already using these canonical links, just in an incomplete way: The Python documentation for 2.7 and 3.5 and later has a <link rel="canonical"> pointing to the generic documentation URL of the same major Python version, e.g. in https://docs.python.org/3/library/functools.html you can find this in the page source: <link rel="canonical" href="https://docs.python.org/3/library/functools.html" /> This is why if you search for "python 3 $module" in Google, you'll never see a direct link to the 3.5 or 3.6 versions of the documentation (because Google merges them with the generic docs.python.org/3/), but you still results for versions 3.2, 3.3 etc. of the documentation (because the lack the canonical links). A very good step would be to also add this canoncial link to the documentation versions 3.0-3.4, this will make docs.python.org/3.3/ etc. vanish from Google and probably rank the generic docs.python.org/3/ higher than now. And now to the abuse part (I'm honestly not sure how well this would actually work): If you would add such a canonical link in docs.python.org/2/ pointing to docs.python.org/3/ (at least where the same module exists in both versions), you would eventually hide /2/ from the search results. If you don't want to be so extreme (people still want Python 2 documentation if they search for "python 2 $module") you could remove the canonical link just from the specific docs.python.org/2.7/ which will then be ranked much lower than docs.python.org/3/ in the search results, but at least still show up. Sebastian

Sebastian Krause <sebastian@realpath.org> wrote:
Here is Nick Coghlan's bpo issue which added these canonical links: https://bugs.python.org/issue26355 - looks like applying this to the older doc versions never happened in the end.

On 7 September 2017 at 12:24, Sebastian Krause <sebastian@realpath.org> wrote:
Right, as adding those will need to be handled through the web server and/or by manually regenerating the docs with the additional HTML headers - making the changes to the CPython repo won't achieve anything, since the docs for those branches aren't automatically regenerated anymore. Another big task that could be undertaken is to start re-routing unqualified deep links to Python 3 - the reason we still haven't done that is because the tree layout is actually different (as per the six.moves module), so it isn't a trivial rewrite rule the way the current redirection into the Python 2 docs is. Given such a mapping, it would also be possible to add the corresponding canonical URL entries to the Python 2.7 documentation to merge their search ranking in to the corresponding Python 3 pages. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (9)
-
Bar Harel
-
Guido van Rossum
-
Nick Coghlan
-
Philipp A.
-
Ryan Gonzalez
-
Sebastian Krause
-
Steven D'Aprano
-
Victor Stinner
-
Wes Turner