mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-20 10:23:16 -05:00
fix: announce the sitemap from each page
This commit is contained in:
1 parent
6c50e29dfa
commit
e56621de42
3 files changed
+23
-6
No files matched your search
@@ -23,6 +23,10 @@
|
||||
{% if page_url %}<meta property="og:url" content="{{ page_url }}">{% endif %}
|
||||
{% if preview_image %}<meta property="og:image" content="{{ preview_image }}">{% endif %}
|
||||
|
||||
{# The sitemap, named from every page: a project site under /retrobios/
|
||||
cannot serve the host-root robots.txt that would announce it. #}
|
||||
{% if config.site_url %}<link rel="sitemap" type="application/xml" title="Sitemap" href="{{ config.site_url }}sitemap.xml">{% endif %}
|
||||
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="{{ page_title }}">
|
||||
<meta name="twitter:description" content="{{ page_description }}">
|
||||
|
||||
@@ -4226,12 +4226,10 @@ def _generate(args: argparse.Namespace) -> None:
|
||||
js_dest.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(js_src, js_dest)
|
||||
|
||||
# mkdocs writes sitemap.xml but no robots.txt, so nothing points a crawler
|
||||
# at it. Everything published here is meant to be indexed.
|
||||
write_if_changed(
|
||||
str(docs / "robots.txt"),
|
||||
"User-agent: *\nAllow: /\n\nSitemap: https://abdess.github.io/retrobios/sitemap.xml\n",
|
||||
)
|
||||
# No robots.txt: a crawler reads it only at the host root (RFC 9309), and
|
||||
# this project site lives under /retrobios/. Every page's head points at
|
||||
# the sitemap instead (overrides/main.html).
|
||||
(docs / "robots.txt").unlink(missing_ok=True)
|
||||
|
||||
# Copy branding assets
|
||||
images_dest = docs / "assets" / "images"
|
||||
|
||||
@@ -217,5 +217,20 @@ class TheTestingGuideNamesEveryModule(unittest.TestCase):
|
||||
self.assertEqual(missing, [])
|
||||
|
||||
|
||||
|
||||
class TheSitemapIsAnnouncedWhereCrawlersLook(unittest.TestCase):
|
||||
"""robots.txt was published as /retrobios/robots.txt, which no crawler
|
||||
reads (RFC 9309 reads the host root): the sitemap it announced was
|
||||
never found that way."""
|
||||
|
||||
def test_the_head_names_it_and_no_robots_is_written(self):
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
override = (root / "docs_assets" / "overrides" / "main.html").read_text()
|
||||
self.assertIn('rel="sitemap"', override)
|
||||
source = (root / "scripts" / "generate_site.py").read_text()
|
||||
self.assertNotIn('"robots.txt"),\n "User-agent', source)
|
||||
self.assertNotIn("Sitemap: https://", source)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user