stefandoorn / sitemap-plugin
Sitemap Plugin for Sylius
Installs: 839 721
Dependents: 2
Suggesters: 4
Security: 0
Stars: 79
Watchers: 4
Forks: 45
Open Issues: 31
Type:sylius-plugin
Requires
- php: ^7.4 || ^8.0
- sylius/sylius: ~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0 || ~1.13.0
Requires (Dev)
- api-platform/core: ~2.5.0 || ~2.6.0 || ~2.7.0
- 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
- sylius-labs/coding-standard: ^4.0
- symfony/browser-kit: ^4.4 || ^5.4 || ^6.4
- symfony/debug-bundle: ^4.4 || ^5.4 || ^6.4
- symfony/dotenv: ^4.4 || ^5.4 || ^6.4
- symfony/intl: ^4.4 || ^5.4 || ^6.4
- symfony/web-profiler-bundle: ^4.4 || ^5.4 || ^6.4
- symfony/webpack-encore-bundle: ^1.15
- vimeo/psalm: 4.23.0
Conflicts
- twig/twig: <2.9
- v2.3.0
- 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-no-buffered-response
- 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-10-31 13:51:32 UTC
README
Big thanks
Goes out to the Sylius team. The core code of this plugin is created by the Sylius team. Unfortunately it got removed from the Sylius core. Luckily the Sylius team approved the extraction to a separate bundle.
Features
- Creates a sitemap index file to point to sub sitemap files per type of data
- Default providers: taxons, products & static content (homepage & contact)
- Easily add your own providers
- Product provider supports locales (hreflang) & is channel aware
- Taxon provider supports locales (hreflang)
Installation
- Run
composer require stefandoorn/sitemap-plugin
. - Add to
app/config/bundles.php
:
SitemapPlugin\SitemapPlugin::class => ['all' => true],
- Add to
app/config/packages/_sylius.yaml
:
- { resource: "@SitemapPlugin/Resources/config/config.yaml" }
- Add to
app/config/routes.yaml
:
sylius_sitemap:
resource: "@SitemapPlugin/Resources/config/routing.yml"
-
Add to
app/config/packages/sylius_sitemap.yaml
: -
Forcing HTTPS on Generated URLs, see Symfony Docu. In console commands, where there is no HTTP request, URLs use http by default. You can change this globally with these configuration parameters:
# config/services.yaml
parameters:
router.request_context.scheme: 'https'
Usage
Generate your sitemap from the CLI:
$ bin/console sylius:sitemap:generate
Add this command to your cronjob to regularly generate a new sitemap, e.g. once a day.
If you only want to generate the sitemap for a specific channel, use:
$ bin/console sylius:sitemap:generate --channel=US_WEB
The plugin defines three default URI's:
sitemap.xml
: redirects tositemap_index.xml
sitemap_index.xml
: renders the sitemap index file (with links to the provider xml files)
Next to this, each provider registeres it's own URI. Take a look in the sitemap index file for the correct URI's.
Default Configuration
Get a full list of configuration: 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: [] }
The request context is also important for generating the URLs inside the sitemap:
- The hostname is defined per channel, if nothing set it defaults to
localhost
- Other request context settings can be adjusted as mentioned in the Symfony docs
Default storage
By default the sitemaps will be saved in %kernel.root_dir%/var/sitemap
. You can change this setting
by adjusting the parameter sylius.sitemap.path
.
Feature switches
providers
: Enable/disable certain providers to be included in the sitemap. Defaults are true.exclude_taxon_root
: Often you don't want to include the root of your taxon tree as it has a generic name as 'products'.hreflang
: Whether to generate alternative URL versions for each locale. Defaults to true. Background: https://support.google.com/webmasters/answer/189077?hl=en.images
: Whether to add images to URL output in case the provider adds them. Defaults to true. Background: https://support.google.com/webmasters/answer/178636?hl=en.
Default providers
- Products
- Taxons
- Static content (homepage & contact)
Add own provider
- Register & tag your provider service with
sylius.sitemap_provider
- Let your provider implement
UrlProviderInterface
- Use one of the default providers as an example to implement code