Git Product home page Git Product logo

sitemap-plugin's Introduction

Sylius Sitemap Plugin

License Version Build Coverage Status

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

  1. Run composer require stefandoorn/sitemap-plugin.
  2. Add to app/config/bundles.php:
  SitemapPlugin\SitemapPlugin::class => ['all' => true],
  1. Add to app/config/packages/_sylius.yaml:
    - { resource: "@SitemapPlugin/Resources/config/config.yaml" }
  1. Add to app/config/routes.yaml:
sylius_sitemap:
    resource: "@SitemapPlugin/Resources/config/routing.yml"
  1. Add to app/config/packages/sylius_sitemap.yaml:

  2. 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 to sitemap_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

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

sitemap-plugin's People

Contributors

alexrowesoap avatar david-crty avatar dependabot-preview[bot] avatar dependabot[bot] avatar jbcr avatar jeroen-g avatar jmwill86 avatar kpitn avatar lamasfoker avatar loevgaard avatar lruozzi9 avatar margauxfeslard avatar mirondi avatar mmenozzi avatar phakpoom avatar roshyo avatar seblours avatar stefandoorn avatar sweoggy avatar tsogoo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.