diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
new file mode 100644
index 00000000..78aeb6c6
--- /dev/null
+++ b/docs/_templates/layout.html
@@ -0,0 +1,25 @@
+{# This extension of the 'layout.html' prevents documentation for previous
+ versions of Astropy to be indexed by bots, e.g. googlebot or bing bot,
+ by inserting a robots meta tag into pages that are not in the stable or
+ latest branch.
+
+ It assumes that the documentation is built by and hosted on readthedocs.org:
+ 1. Readthedocs.org has a global robots.txt and no option for a custom one.
+ 2. The readthedocs app passes additional variables to the template context,
+ one of them being `version_slug`. This variable is a string computed from
+ the tags of the branches that are selected to be built. It can be 'latest',
+ 'stable' or even a unique stringified version number.
+
+ For more information, please refer to:
+ https://github.com/astropy/astropy/pull/7874
+ http://www.robotstxt.org/meta.html
+ https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/builds/version_slug.py
+#}
+
+{% extends "!layout.html" %}
+{%- block extrahead %}
+ {% if not version_slug in to_be_indexed %}
+
+ {% endif %}
+ {{ super() }}
+{% endblock %}
diff --git a/docs/conf.py b/docs/conf.py
index 7ffff3f5..7a9c7d7c 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -12,9 +12,9 @@
# See astropy.sphinx.conf for which values are set there.
from configparser import ConfigParser
-from astroplan import __version__
import sys
import datetime
+from importlib import metadata
try:
from sphinx_astropy.conf.v2 import * # noqa
@@ -70,10 +70,17 @@
__import__(project)
package = sys.modules[project]
-# The short X.Y version.
-version = package.__version__.split('-', 1)[0]
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+
# The full version, including alpha/beta/rc tags.
-release = package.__version__
+release = metadata.version(project)
+# The short X.Y version.
+version = ".".join(release.split(".")[:2])
+
+# Only include dev docs in dev version.
+dev = "dev" in release
# -- Options for HTML output ---------------------------------------------------
@@ -173,9 +180,6 @@
# -- Turn on nitpicky mode for sphinx (to warn about references not found) ----
nitpicky = True
-release = __version__
-dev = "dev" in release
-
html_copy_source = False
html_theme_options.update( # noqa: F405
@@ -198,6 +202,11 @@
"doc_path": "docs",
}
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+html_extra_path = ["robots.txt"]
+
#
# Some warnings are impossible to suppress, and you can list specific references
# that should be ignored in a nitpick-exceptions file which should be inside
diff --git a/docs/index.rst b/docs/index.rst
index 5e48fce6..4977c01f 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -31,8 +31,8 @@ License: BSD-3
.. _astroplan_docs:
-General Documentation
-=====================
+Documentation
+=============
.. toctree::
:maxdepth: 2
@@ -44,13 +44,8 @@ General Documentation
api
changelog
-.. _astroplan_authors:
-
-Authors
-=======
-
Maintainers
------------
++++++++++++
* `Brett Morris, including contributions from Google Summer of Code 2015 `_
Attribution
diff --git a/docs/robots.txt b/docs/robots.txt
new file mode 100644
index 00000000..df810cf3
--- /dev/null
+++ b/docs/robots.txt
@@ -0,0 +1,6 @@
+User-agent: *
+Allow: /*/latest/
+Allow: /en/latest/ # Fallback for bots that don't understand wildcards
+Allow: /*/stable/
+Allow: /en/stable/ # Fallback for bots that don't understand wildcards
+Disallow: /