Skip to content

Commit ab64878

Browse files
committed
Return sitemap on robots.txt file
1 parent 3de35d0 commit ab64878

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
@@ -295,7 +295,14 @@ def robots_txt(request, project):
295295
if os.path.exists(fullpath):
296296
return HttpResponse(open(fullpath).read(), content_type='text/plain')
297297

298-
return HttpResponse('User-agent: *\nAllow: /\n', content_type='text/plain')
298+
sitemap_url = '{scheme}://{domain}/sitemap.xml'.format(
299+
scheme='https',
300+
domain=project.subdomain(),
301+
)
302+
return HttpResponse(
303+
'User-agent: *\nAllow: /\nSitemap: {}\n'.format(sitemap_url),
304+
content_type='text/plain',
305+
)
299306

300307

301308
@map_project_slug

0 commit comments

Comments
 (0)