stefandoorn / sitemap-plugin
Sylius 的 Sitemap 插件
v2.2.0
2023-08-15 12:30 UTC
Requires
- php: ^7.4 || ^8.0
- sylius/sylius: ~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0
Requires (Dev)
- api-platform/core: ~2.5.0 || ~2.6.0 || ~2.7.0
- friendsofsymfony/oauth-server-bundle: ^1.6 || >2.0.0-alpha.0 ^2.0@dev
- lchrusciel/api-test-case: ^5.1
- league/flysystem-bundle: ^2.0 || ^3.0
- matthiasnoback/symfony-dependency-injection-test: ^4.3
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.2
- phpstan/phpstan-doctrine: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
- phpstan/phpstan-symfony: ^1.0
- phpstan/phpstan-webmozart-assert: ^1.0
- phpunit/phpunit: ^9.5
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^4.0
- sylius/mailer-bundle: ^1.8 || ^2.0@beta
- symfony/browser-kit: ^4.4 || ^5.4
- symfony/debug-bundle: ^4.4 || ^5.4
- symfony/dotenv: ^4.4 || ^5.4
- symfony/intl: ^4.4 || ^5.4
- symfony/web-profiler-bundle: ^4.4 || ^5.4
- symfony/webpack-encore-bundle: ^1.15
- vimeo/psalm: 4.23.0
Conflicts
- twig/twig: <2.9
- v2.2.0
- v2.1.1
- v2.1.0
- dev-master / 2.0.x-dev
- v2.0.1
- v2.0.0
- v2.0.0-beta
- v2.0.0-alpha.9
- v2.0.0-alpha.8
- v2.0.0-alpha.7
- v2.0.0-alpha.6
- v2.0.0-alpha.5
- v2.0.0-alpha.4
- v2.0.0-alpha.3
- v2.0.0-alpha.2
- v2.0.0-alpha.1
- v1.x-dev
- v1.1.1
- v1.1.0
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- 0.5
- 0.4
- 0.3
- 0.2
- 0.1
- dev-remove-mailer
- dev-remove-parent-construct
- dev-dependabot/composer/vimeo/psalm-5.12.0
- dev-ci/sf6
- dev-versions/v2.1
- dev-revert-ecs-trailing-comma
- dev-move-deps-to-dev
- dev-security
- dev-ci-more
- dev-ci/actions-checkout-v3
- dev-ci/node14
- dev-ci/sf5-version
- dev-ci/symfony-v4.4
- dev-ci/sylius1.11
- dev-maintenance/php8.1
- dev-maintenance/sylius-1.9
- dev-maintenance/ci
- dev-dependabot/composer/symfony/intl-tw-5.2
- dev-feat/bc-check-ci
- dev-maintenance/symfony-bundles-dev
- dev-feat/phpunit-9
- dev-maintenance/require-php8-to-pass
- dev-feat/composer-cache
- dev-maintenance/phpstan-upgrade-level-1
- dev-maintenance/actions-run-on-pr
- dev-dependabot/composer/symfony/dotenv-tw-5.2
- dev-feat/split-big-sitemaps
- dev-no-exception-but-just-return
- dev-feat/read-stream
- dev-feature/generate-cli-using-providers
- dev-feature/generate-cli
- dev-maintenance/controller-tests
- dev-feature/drop-relative-url-support
- dev-maintenance/remove-temp-provider-exclude
- dev-maintenance/sylius-1.4
This package is auto-updated.
Last update: 2024-09-02 16:27:22 UTC
README
感谢
向 Sylius 团队表示感谢。此插件的核心代码由 Sylius 团队创建。不幸的是,它被从 Sylius 核心中移除。幸运的是,Sylius 团队批准将其提取为单独的包。
功能
- 创建指向子 sitemap 文件的 sitemap 指引文件,每个文件对应一种数据类型
- 默认提供者:分类、产品 & 静态内容(首页 & 联系我们)
- 轻松添加自己的提供者
- 产品提供者支持地区(hreflang)且具有渠道意识
- 分类提供者支持地区(hreflang)
安装
- 运行
composer require stefandoorn/sitemap-plugin
。 - 添加到
app/config/bundles.php
SitemapPlugin\SitemapPlugin::class => ['all' => true],
- 添加到
app/config/packages/_sylius.yaml
- { resource: "@SitemapPlugin/Resources/config/config.yaml" }
- 添加到
app/config/routes.yaml
sylius_sitemap:
resource: "@SitemapPlugin/Resources/config/routing.yml"
-
添加到
app/config/packages/sylius_sitemap.yaml
-
在生成的 URL 上强制使用 HTTPS,请参阅 Symfony 文档。在控制台命令中,因为没有 HTTP 请求,所以 URL 默认使用 http。您可以使用这些配置参数全局更改此设置。
# config/services.yaml
parameters:
router.request_context.scheme: 'https'
使用方法
从 CLI 生成您的 sitemap
$ bin/console sylius:sitemap:generate
将此命令添加到您的 cronjob 以定期生成新的 sitemap,例如每天一次。
如果您只想为特定渠道生成 sitemap,请使用
$ bin/console sylius:sitemap:generate --channel=US_WEB
该插件定义了三个默认 URI
sitemap.xml
: 重定向到sitemap_index.xml
sitemap_index.xml
: 渲染 sitemap 指引文件(包含指向提供者 xml 文件的链接)
此外,每个提供者都注册了自己的 URI。请查看 sitemap 指引文件以获取正确的 URI。
默认配置
获取完整的配置列表:bin/console config:dump-reference sitemap
sitemap: providers: products: true taxons: true static: true template: '@SitemapPlugin/show.xml.twig' index_template: '@SitemapPlugin/index.xml.twig' exclude_taxon_root: true hreflang: true images: true static_routes: - { route: sylius_shop_homepage, parameters: [], locales: [] } - { route: sylius_shop_contact_request, parameters: [], locales: [] }
请求上下文对于生成 sitemap 中的 URL 也非常重要
- 主机名按渠道定义,如果没有设置,则默认为
localhost
- 其他请求上下文设置可以像在 Symfony 文档 中所述进行调整
默认存储
默认情况下,sitemap 将保存到 %kernel.root_dir%/var/sitemap
。您可以通过调整参数 sylius.sitemap.path
来更改此设置。
功能开关
providers
: 启用/禁用某些提供者以包含在 sitemap 中。默认值为 true。exclude_taxon_root
: 通常您不希望包含您的分类树根,因为它的名称很通用,如“产品”。hreflang
: 是否为每个地区生成替代 URL 版本。默认值为 true。背景:https://support.google.com/webmasters/answer/189077?hl=en。images
: 是否在提供者添加图像的情况下将图像添加到 URL 输出中。默认值为 true。背景:https://support.google.com/webmasters/answer/178636?hl=en。
默认提供者
- 产品
- 分类
- 静态内容(首页 & 联系我们)
添加自己的提供者
- 使用
sylius.sitemap_provider
注册并标记您的提供者服务 - 让您的提供者实现
UrlProviderInterface
- 使用默认提供者之一作为示例实现代码