【问题标题】:django: show sitemap.xmldjango:显示 sitemap.xml
【发布时间】:2015-06-12 11:34:04
【问题描述】:

我有一个sitemap.xml 文件。其内容:

<?xml version="1.0" encoding="UTF-8" ?>
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
    <url>
    ...
    </url>
    <url>
     ...
    </url>
    <url>
    ...
    </url>
</urlset>

当我在http://www.example.com/sitemap.xml 显示它时:我得到:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>

我没有看到所有的网址!是bug吗?

这是urls.py 文件:

(r'^sitemap\.xml/$', TemplateView.as_view(template_name='sitemap.xml', content_type='text/xml'))

【问题讨论】:

标签: django sitemap django-urls


【解决方案1】:

Django 站点地图框架不适用于我: https://docs.djangoproject.com/en/1.8/ref/contrib/sitemaps/ 在网络浏览器中检查 sitemap.xml 文件时,我看不到任何 url 标签。

但是,我使用了一个网站来自动生成它: http://www.web-site-map.com/xml_sitemap.php

现在我可以看到 sitemap.xml 文件的全部内容了 :)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    相关资源
    最近更新 更多