Skip to content

Commit a40b493

Browse files
committed
Return sitemap on robots.txt file
1 parent 8a42529 commit a40b493

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

readthedocs/core/views/serve.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,14 @@ def robots_txt(request, project):
312312
if os.path.exists(fullpath):
313313
return HttpResponse(open(fullpath).read(), content_type='text/plain')
314314

315-
return HttpResponse('User-agent: *\nAllow: /\n', content_type='text/plain')
315+
sitemap_url = '{scheme}://{domain}/sitemap.xml'.format(
316+
scheme='https',
317+
domain=project.subdomain(),
318+
)
319+
return HttpResponse(
320+
'User-agent: *\nAllow: /\nSitemap: {}\n'.format(sitemap_url),
321+
content_type='text/plain',
322+
)
316323

317324

318325
@map_project_slug

0 commit comments

Comments
 (0)