Skip to content

Commit

Permalink
[DOCS] Add proper robots.txt and sitemap.xml to index only latest and…
Browse files Browse the repository at this point in the history
… stable (#1752)

Solution proposed here:
https://stackoverflow.com/questions/63542354/readthedocs-robots-txt-and-sitemap-xml

---------

Co-authored-by: Jay Chia <[email protected]@users.noreply.github.com>
  • Loading branch information
jaychia and Jay Chia authored Dec 20, 2023
1 parent 52b5209 commit 03f6dac
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/source/_html/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
User-agent: *

# Allow crawling of all paths
Allow: /

# Override to disallow crawling of documentation
Disallow: /projects/docs/

# Override again to allow crawling of /latest documentation
Allow: /projects/docs/en/latest/

# Override again to allow crawling of /stable documentation
Allow: /projects/docs/en/stable/

# Custom sitemap
Sitemap: https://www.getdaft.io/sitemap-override.xml
19 changes: 19 additions & 0 deletions docs/source/_html/sitemap-override.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://www.getdaft.io/projects/docs/en/latest/</loc>
<changefreq>daily</changefreq>
<priority>1</priority>
</url>
<url>
<loc>https://www.getdaft.io/projects/docs/en/stable/</loc>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://www.getdaft.io/</loc>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
"learn/10-min": "../10-min.html",
}

# Adds /_html folder which serves robots.txt and the sitemap
html_extra_path = ["_html"]

# Resolving code links to github
# Adapted from: https://github.com/aaugustin/websockets/blob/778a1ca6936ac67e7a3fe1bbe585db2eafeaa515/docs/conf.py#L100-L134

Expand Down

0 comments on commit 03f6dac

Please sign in to comment.