Skip to content

Serve sitemap via static robots.txt; drop dead Django robots view (#1252) - #1308

Merged
jonfroehlich merged 1 commit into
masterfrom
1252-robots-followup
Jun 15, 2026
Merged

Serve sitemap via static robots.txt; drop dead Django robots view (#1252)#1308
jonfroehlich merged 1 commit into
masterfrom
1252-robots-followup

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

Follow-up to #1307 (sitemap work). Refs #1252.

Why

The test deploy revealed how /robots.txt is actually served:

  • /sitemap.xmlDjango (Server: WSGIServer) — our dynamic sitemap works.
  • /robots.txtApache static file (Server: Apache, with ETag/Last-Modified/Accept-Ranges) served from the project checkout on the Docker host — Apache never forwards /robots.txt to Django.

The served content matches the repo's tracked top-level ./robots.txt (whose git history — "changed the robots.txt to reflect the behavior we want for the production site" — confirms it's the production robots file). So the Django robots_txt view added in #1307 was dead code in every server environment; it only ran under local runserver, which diverges from prod. The test-server "don't index" concern it tried to solve is already handled at the server level (Apache stamps X-Robots-Tag: noindex, nofollow on the whole test host).

Changes

  • robots.txt — add the Sitemap: directive (points crawlers like Bing/Google at the dynamic sitemap); keep allow-all crawling, matching the existing production behavior.
  • Remove website/views/robots.py, its re-export in website/views/__init__.py, and the /robots.txt URL route. Added a comment in makeabilitylab/urls.py pointing future edits at the static ./robots.txt.
  • Tests — drop the (now irrelevant) robots view tests; sitemap tests unchanged.

The dynamic sitemap itself (django.contrib.sitemaps) is unchanged and already verified live on the test server.

Single source of truth

robots.txt is now unambiguously a static file served by Apache. To change crawler rules or the sitemap URL, edit the top-level ./robots.txt.

Testing

  • Ran 165 tests ... OK (3 fewer than before = the removed robots view tests).
  • Will re-verify on the test server post-merge that the served /robots.txt picks up the new Sitemap: line (confirming the repo file is the served file), then crawl-validate the sitemap before cutting a prod tag.

Note (no UI change)

Non-visual change; no screenshots.

🤖 Generated with Claude Code

)

Follow-up to the sitemap work. On the servers Apache serves the static
top-level ./robots.txt from the project checkout and never forwards
/robots.txt to Django, so the robots_txt view added earlier was dead code
in every server environment (it only ran under local runserver, which
diverges from prod). Confirmed via the test deploy: /sitemap.xml is served
by Django (WSGIServer) while /robots.txt comes from Apache as a static file,
and the served content matches this tracked ./robots.txt.

- robots.txt: advertise the sitemap (Sitemap: line); keep allow-all crawling.
- Remove website/views/robots.py, its re-export, and the /robots.txt route;
  add a comment in urls.py pointing future edits at the static file.
- Drop the now-irrelevant robots view tests; sitemap tests unchanged.

The dynamic sitemap (django.contrib.sitemaps) is unchanged and already
verified on the test server.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jonfroehlich
jonfroehlich merged commit 44eb378 into master Jun 15, 2026
1 check passed
@jonfroehlich
jonfroehlich deleted the 1252-robots-followup branch June 22, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant