isaactopo / xmlsitemap
Kirby 3 多语言 XML 网站地图
Requires
README
这是一个强大的工具,用于管理和生成与 Kirby 3 配合使用的网站地图。此插件提供了一种简单的方法来创建 XML 网站地图,特别是针对多语言网站。多语言支持允许您为每种语言创建独立的 URL,从而提高您网站的 SEO 性能。该插件创建一个包含指向您网站页面和图片的 URL 的 XML 文件,并自动分配其优先级和最后修改日期,这些可以在以后轻松由搜索引擎读取。
如果网站只使用一种语言,将在 /sitemap.xml
中生成网站地图。在新版本(0.2.0)中,如果网站有两种或更多语言,将在 sitemap.xml
中生成 <sitemapindex>
,并为每种语言生成所有子网站地图,格式如下: sitemap_en.xml
、sitemap_es.xml
等。
安装方法
下载
下载并复制此存储库 到 /site/plugins/xmlsitemap
作为 Git 子模块
git submodule add https://github.com/isaactopo/xmlsitemap.git site/plugins/xmlsitemap
使用 Composer
composer require isaactopo/xmlsitemap
设置
插件从开始工作,将网站上的所有列表页面输出到 yoursite/sitemap.xml
,并将 yoursite/sitemap
重定向到 yoursite/sitemap.xml
选项和配置
您可以从 site/config.php
文件中调整插件中的 3 个配置选项
🙈 忽略页面
默认情况下,未列出页面将被忽略,但有时您可能想要忽略特定页面。您可以使用以下方法来实现
'isaactopo.xmlsitemap.ignore' => ['error', 'legal'],
🎆 包含图片
您可以使用以下方法来包含图片
'isaactopo.xmlsitemap.includeImages' => true,
🧾 包含特定页面
如果您有一些来自路由或其他页面的工厂生成页面,并想强制包含它们,可以使用以下方法
'isaactopo.xmlsitemap.addCollection' => function () { $professionals = kirby()->users()->filterBy('publish', true); $profiles = []; foreach($professionals as $professional){ $profiles[] = Page::factory([ 'slug' => 'team/'.$professional, 'template' => 'profile', 'content' => [ 'author' => $professional, ] ]); } return $profiles; },
🛗 改变页面优先级
插件根据每个页面的深度自动生成优先级(感谢 Bastian)。但您可能想要手动更改某些页面的优先级。如果是这样,您可以在要包含的页面的蓝图创建一个新的字段
sitemapPriority: label: Sitemap Priority type: number width: 1/2 max: 1 min: 0 step: 0.1
这样,插件将优先考虑来自面板的输入。
致谢
- Isaac Bordons https://topo.bz — https://morethanlaw.es
- 感谢 Bastian Allgeier 的 Cookbook 文章 以及 Pedro Borges 的 K2 XML Sitemap 插件