halo-dev / plugin-sitemap

Halo 2.0 的站点 Sitemap 生成插件
https://halo.run/store/apps/app-QDFMI
GNU General Public License v3.0
6 stars 6 forks source link

请求支持自动分割Sitemap以处理超过300个链接的站点 #35

Open eden2f opened 3 months ago

eden2f commented 3 months ago

您好,Halo开发团队!

首先,非常感谢你们创建并维护了如此出色的博客框架。我在使用Halo搭建博客时遇到了一个关于站点地图(Sitemap)的问题,特此提出,希望能得到你们的帮助。

问题描述:

目前,许多搜索引擎平台在处理站点地图时,单个sitemap文件支持的链接数量上限通常为300个。然而,随着博客内容的不断增长,尤其是当博客文章数量超过300篇时,Halo默认生成的单个sitemap(位于站点根目录下的sitemap.xml)将无法包含所有页面链接,导致搜索引擎无法完全抓取和索引所有内容。

期望的解决方案:

鉴于上述问题,我恳请Halo官方考虑在后续版本中引入以下功能或提供解决方案:

自动分割Sitemap:根据链接数量自动将sitemap分割成多个文件(如sitemap_index.xml、sitemap1.xml、sitemap2.xml等),并在sitemap_index.xml中列出所有子sitemap文件的位置,以便搜索引擎能够发现并处理所有子sitemap中的链接。 配置文件选项:提供配置选项,允许用户自定义每个sitemap文件的最大链接数,以便根据不同平台的限制进行调整。 文档更新:如果实现了上述功能,请确保在官方文档中详细说明如何配置和使用这些新特性,以帮助用户更好地利用它们来优化站点的SEO。

影响与优势:

实现这一功能将大大提升使用Halo框架的博客在搜索引擎中的可见度和索引效率,特别是对于内容丰富的博客来说,这一改进尤为重要。此外,这也将使得Halo框架在SEO优化方面更加灵活和强大,吸引更多用户采用。

非常感谢你们对社区问题的关注与回应!期待你们的回复和更新。

ruibaby commented 3 months ago

感谢反馈,实现方案可以参考我们使用的论坛(Flarum)的做法,https://bbs.halo.run/sitemaps/sitemap.xml

进一步的建议:将 sitemap 列表按照数据类型进行拆分,其中可能出现过量的数据按照分页区分,比如:

sitemap.xml:

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>https://bbs.halo.run/sitemaps/sitemap-categories.xml</loc>
        <lastmod>2024-05-06T07:17:15+00:00</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://bbs.halo.run/sitemaps/sitemap-tags.xml</loc>
        <lastmod>2024-05-06T07:17:16+00:00</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://bbs.halo.run/sitemaps/sitemap-posts.xml</loc>
        <lastmod>2024-05-06T07:17:16+00:00</lastmod>
    </sitemap>
</sitemapindex>

/sitemaps/sitemap-posts.xml:

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>https://bbs.halo.run/sitemaps/sitemap-post-1.xml</loc>
        <lastmod>2024-05-06T07:17:15+00:00</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://bbs.halo.run/sitemaps/sitemap-post-2.xml</loc>
        <lastmod>2024-05-06T07:17:16+00:00</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://bbs.halo.run/sitemaps/sitemap-post-3.xml</loc>
        <lastmod>2024-05-06T07:17:16+00:00</lastmod>
    </sitemap>
</sitemapindex>

此外,也可以考虑结合 https://github.com/halo-dev/plugin-sitemap/issues/31 实现。比如目前 Halo 的应用市场可能也会有生成 sitemap 的需求。