Django 站点地图和多级索引
我们的项目终于上线了,只是缺少站点地图。由于我必须保持在每个文件 50k 链接的限制之下,我正在考虑如何将站点地图拆分为多个级别。
我们三个主要部分之间的基本共同结构是位置。
每个位置基于 3 个级别,所有级别都可以生成相同的 url 模式。我将用一些伪代码更好地解释。
Location levels:
- area
- area -> district
- area -> district -> city
core 1 has 4 additional parameters
core 2 has 5 additional parameters
core 3 has 3 additional parameters
for core 1 (example) we can have:
- /area/param1/param2/param3/param4/
- /area/district/param1/param2/param3/param4/
等等。所以我想在我的 sitemap.xml 索引文件中显式地处理所有 sitemap-.xml,其中部分是位置级别。类似这样的:
sitemap-us.xml
sitemap-us-alabama.xml
sitemap-us-alabama-whatever.xml
sitemap-us-alabama-whatever-reallyidontknowcitieshere.xml
在每一个中,我都会调用 Sitemap 方法,该方法应该检查位置参数并生成 url。你怎么认为?这个解决方案正确吗?还有其他建议吗?最好的想法是我用一个站点地图方法编写所有内容,然后 django 自己处理 50k 的限制(我猜这是不可能的……)
finally our project is going live, and we're just missing the sitemap. Since i have to stay under the 50k links per file limit, i was thinking how to split my sitemaps in multiple levels.
Basic common structure between our 3 main sections is the LOCATION.
Each location is based on 3 levels, all of which can generate the same url patterns. I'll explain better with some pseudocode.
Location levels:
- area
- area -> district
- area -> district -> city
core 1 has 4 additional parameters
core 2 has 5 additional parameters
core 3 has 3 additional parameters
for core 1 (example) we can have:
- /area/param1/param2/param3/param4/
- /area/district/param1/param2/param3/param4/
And so on. So i was thinking in my sitemap.xml index file to explicitly address all sitemap-.xml, where section is the location levels. Sometihing like:
sitemap-us.xml
sitemap-us-alabama.xml
sitemap-us-alabama-whatever.xml
sitemap-us-alabama-whatever-reallyidontknowcitieshere.xml
And in every one of them i'll call the Sitemap method, which should check the location params and generate urls. What do you think? Is this solution correct? Any other suggestions? Best think would be me writing everything in a single sitemap method and django handling the 50k limit by itself (which isn't possible atm, i guess...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Django 1.3 新增内容
https://docs。 djangoproject.com/en/dev/ref/contrib/sitemaps/#creating-a-sitemap-index
New to Django 1.3
https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/#creating-a-sitemap-index