使用goog制作Django站点地图

2024-04-29 18:59:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我遇到的一个问题是,我怀疑Google正确查看sitemaps.xml的内容类型不正确-它突出了以下问题:

Your Sitemap appears to be an HTML page. Please use a supported sitemap format instead.

所以,我想我需要改变内容类型。我看到了一些奇怪的方法,一切都使用lambdas和HttpResponse解决方案。对于如下的url,有没有一种简单的方法可以将内容类型更改为'text/plain''text/xml'?你知道吗

以下操作无效:

url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps, content_type='plain/xml'}, name='sitemap')

sitemaps = {'views': ViewSitemap}

其中ViewSiteMap是返回静态URL的类。什么是更聪明的方法?你知道吗


Tags: to方法texturl类型内容yourgoogle