Django 站点地图和多级索引

发布于 2024-12-11 10:21:28 字数 848 浏览 0 评论 0原文

我们的项目终于上线了,只是缺少站点地图。由于我必须保持在每个文件 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文