Giter Club home page Giter Club logo

sitemap's Introduction

Sitemap Addon for Statamic

Statamic 3.0+

Automatically adds a sitemap to your Statamic v3 web site. The default path is <your web site>/sitemap.xml

Installation

Include the package with composer:

composer require pecotamic/sitemap

The package requires Laravel 7+ and PHP 7.3+. It will auto register.

Configuration (optional)

You can override the default options by publishing the configuration:

php artisan vendor:publish --provider="Pecotamic\Sitemap\ServiceProvider" --tag=config

This will copy the default config file to config/pecotamic/sitemap.php.

View (optional)

You can also override the view template to adjust the output by publishing the view:

php artisan vendor:publish --provider="Pecotamic\Sitemap\ServiceProvider" --tag=view

The view template will be copied to resources/views/vendor/pecotamic/sitemap/sitemap.blade.php.

If you prefer another view engine, it is also possible. For example to use Antlers, create a file named sitemap.antlers.html instead of the blade template.

View variables

An array of sitemap entries is passed to the view template. Each entry has these properties:

  • loc: The absolute url
  • path: The relative path
  • lastmod: A DateTime object of the last modification date
  • changefreq: A string like 'daily', 'weekly' (optional)
  • priority: A string presenting a float value between 0 and 1 (optional)

Dynamically adding entries (optional)

You may add entries dynamically by providing a closure that returns an array to the addEntries method.

use Pecotamic\Sitemap\Sitemap;
use Pecotamic\Sitemap\SitemapEntry;

class AppServiceProvider extends Provider
{
    public function boot()
    {
        Sitemap::addEntries(static function () {
            return [
                new SitemapEntry('/hidden-page', new \DateTime('2020-02-20')),
                new SitemapEntry('/about-me', new \DateTime('now'), 'daily', '1.0'),
            ];
        });
    }
}

Credits

Thanks for code contribution to Prageeth Silva and Poh Nean.

sitemap's People

Contributors

fr6 avatar pohnean avatar prageeth avatar steffenschmidt avatar werner-freytag 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.