PHPackages                             locomotivemtl/charcoal-contrib-sitemap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. locomotivemtl/charcoal-contrib-sitemap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

locomotivemtl/charcoal-contrib-sitemap
======================================

Charcoal service for generating a sitemap.

0.4.1(1y ago)01.7k1MITPHPPHP &gt;=5.6.0 || &gt;=7.0

Since Jun 1Pushed 3mo ago12 watchersCompare

[ Source](https://github.com/locomotivemtl/charcoal-contrib-sitemap)[ Packagist](https://packagist.org/packages/locomotivemtl/charcoal-contrib-sitemap)[ Docs](https://locomotivemtl.github.io/charcoal-contrib-sitemap/)[ RSS](/packages/locomotivemtl-charcoal-contrib-sitemap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (14)Used By (1)

Charcoal Sitemap
================

[](#charcoal-sitemap)

[![License](https://camo.githubusercontent.com/7bfa951670760fc888b0447b6116419a75a9b56330dc93625f008414b0c2dbba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/locomotivemtl/charcoal-contrib-sitemap)[![Latest Stable Version](https://camo.githubusercontent.com/f8d175a97b866aa0b3eb11bd72e9cd3426945592c51f061965edbd8b395d46cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/locomotivemtl/charcoal-contrib-sitemap)[![Code Quality](https://camo.githubusercontent.com/e6e47f300e2de8efd0b0a15a0582af888c2d200eda8c1b8aba02458010701888/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/locomotivemtl/charcoal-contrib-sitemap/)[![Coverage Status](https://camo.githubusercontent.com/b555a2fea384a61d2bf383c09c5d6669e5e82cea412383292f5964c78ecf3cd4/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/locomotivemtl/charcoal-contrib-sitemap)[![Build Status](https://camo.githubusercontent.com/e1b753627886afab2b18a1ab7691a1a76db85f95851ce5c80810fbdbacda637b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://app.travis-ci.com/github/locomotivemtl/charcoal-contrib-sitemap)

A [Charcoal](https://packagist.org/packages/locomotivemtl/charcoal-app) service for generating a sitemap.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Dependencies](#dependencies)
- [Service Provider](#service-provider)
    - [Services](#services)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Using the builder](#using-the-builder)
    - [Sitemap.xml](#sitemap.xml)
- [Development](#development)
    - [Development Dependencies](#development-dependencies)
    - [Coding Style](#coding-style)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

The preferred (and only supported) method is with Composer:

```
$ composer require locomotivemtl/charcoal-contrib-sitemap
```

### Dependencies

[](#dependencies)

#### Required

[](#required)

- **[PHP 5.6+](https://php.net)**: *PHP 7* is recommended.
- **[locomotivemtl/charcoal-app](https://packagist.org/packages/locomotivemtl/charcoal-app)**: ^0.8
- **[locomotivemtl/charcoal-core](https://packagist.org/packages/locomotivemtl/charcoal-core)**: ^0.3
- **[locomotivemtl/charcoal-factory](https://packagist.org/packages/locomotivemtl/charcoal-factory)**: ^0.4
- **[locomotivemtl/charcoal-object](https://packagist.org/packages/locomotivemtl/charcoal-object)**: ^0.4
- **[locomotivemtl/charcoal-translator](https://packagist.org/packages/locomotivemtl/charcoal-translator)**: ^0.3

Service Provider
----------------

[](#service-provider)

### Services

[](#services)

- **charcoal/sitemap/builder** Instance of `Charcoal\Sitemap\Service\Builder`. Used to generate collections of links from the configured models.

Configuration
-------------

[](#configuration)

The Sitemap can be configured from the application configset under the `sitemap` key. You can setup which objects to be included and available translations (l10n).

Most options are renderable by objects using your application's chosen template syntax (Mustache used in examples below).

### Default Options

[](#default-options)

```
{
    /**
     * The service's configuration point.
     */
    "sitemap": {
        /**
         * One or more groups to customize how objects should be processed.
         *
         * The array key is an arbitrary identifier for the grouping of models.
         */
        "": {
            /**
             * Whether or not to include links to translations.
             *
             * - `true` — Multilingual. Include all translations
             *   (see `locales.languages`).
             * - `false` — Unilingual. Include only the default language
             *   (see `locales.default_language`).
             */
            "l10n": false,
            /**
             * The language to include a link to if group is unilingual.
             *
             * If `l10n` is `true`, this option is ignored.
             *
             * Defaults to the application's current language.
             */
            "locale": "",
            /**
             * Whether or not to check if the routable object
             * has an active route (`RoutableInterface#isActiveRoute()`)
             *
             * - `true` — Include only routable objects with active routes.
             * - `false` — Ignore if a routable object's route is active.
             */
            "check_active_routes": false,
            /**
             * Whether or not to prepend relative URIs with
             * the application's base URI (see `base_url`).
             *
             * - `true` — Use only the object's URI (see `sitemap.*.objects.*.url`).
             * - `false` — Prepend the base URI if object's URI is relative.
             */
            "relative_urls": false,
            /**
             * The transformer to parse each model included in `objects`.
             *
             * Either a PHP FQCN or snake-case equivalent.
             */
            "transformer": "",
            /**
             * Map of models to include in the sitemap.
             */
            "objects": {
                /**
                 * One or more models to customize and include in the sitemap.
                 *
                 * The array key must be the model's object type,
                 * like `app/model/foo-bar`, or fully-qualified name (FQN),
                 * like `App\Model\FooBar`.
                 */
                "": {
                    /**
                     * The transformer to parse the object.
                     *
                     * Either a PHP FQCN or snake-case equivalent.
                     */
                    "transformer": "",
                    /**
                     * The URI of the object for the `` element.
                     */
                    "url": "{{ url }}",
                    /**
                     * The name of the object. Can be used in a
                     * custom sitemap builder or XML generator.
                     */
                    "label": "{{ title }}",
                    /**
                     * Map of arbitrary object data that can be used
                     * in a custom sitemap builder or XML generator.
                     */
                    "data": {},
                    /**
                     * List or map of collection filters of which objects
                     * to include in the sitemap.
                     *
                     * ```json
                     * "": {
                     *     "property": "active",
                     *     "value": true
                     * }
                     * ```
                     */
                    "filters": [],
                    /**
                     * List or map of collection orders to sort the objects
                     * in the sitemap.
                     *
                     * ```json
                     * "": {
                     *     "property": "position",
                     *     "direction": "ASC"
                     * }
                     * ```
                     */
                    "orders": [],
                    /**
                     * Map of models to include in the sitemap
                     * below this model.
                     *
                     * Practical to group related models.
                     */
                    "children": {
                        /**
                         * One or more models to customize and include in the sitemap.
                         */
                        "": {
                            /**
                             * A constraint on the parent object to determine
                             * if the child model's objects should be included
                             * in the sitemap.
                             */
                            "condition": null
                        }
                    }
                }
            }
        }
    }
}
```

Each model can override the following options of their group: `l10n`, `locale`, `check_active_routes`, `relative_urls`.

### Example

[](#example)

The example below, identified as `footer_sitemap`, is marked as multilingual using the `l10n` option which will include all translations.

```
{
    "sitemap": {
        "footer_sitemap": {
            "l10n": true,
            "check_active_routes": true,
            "relative_urls": false,
            "transformer": "charcoal/sitemap/transformer/routable",
            "objects": {
                "app/object/section": {
                    "transformer": "\\App\\Transformer\\Sitemap\\Section",
                    "label": "{{ title }}",
                    "url": "{{ url }}",
                    "filters": {
                        "active": {
                            "property": "active",
                            "value": true
                        }
                    },
                    "data": {
                        "id": "{{ id }}",
                        "metaTitle": "{{ metaTitle }}"
                    },
                    "children": {
                        "app/object/section-children": {
                            "condition": "{{ isAnObjectParent }}"
                        }
                    }
                }
            }
        }
    }
}
```

Usage
-----

[](#usage)

### Using the builder

[](#using-the-builder)

The builder returns only an array. You need to make your own conversation if you need another format.

The Sitemap module will include all necessary service providers and set the route (sitemap.xml) directly. Include the module:

```
"modules": {
    "charcoal/sitemap/sitemap": {}
}
```

Given the settings above:

```
$builder = $container['charcoal/sitemap/builder'];
$sitemap = $builder->build('footer_sitemap'); // footer_sitemap is the ident of the settings you want.
```

You can also use the `SitemapBuilderAwareTrait`, which includes the setter and getter for the sitemap builder, in order to use it with minimal code in every necessary class.

### Sitemap.xml

[](#sitemapxml)

This contrib provides a route for `sitemap.xml` that dynamically loads the `xml` config and outputs it as an XML for crawlers to read.

Development
-----------

[](#development)

To install the development environment:

```
$ composer install
```

To run the scripts (phplint, phpcs, and phpunit):

```
$ composer test
```

### API Documentation

[](#api-documentation)

- The auto-generated `phpDocumentor` API documentation is available at:

- The auto-generated `apigen` API documentation is available at:
    [https://codedoc.pub/locomotivemtl/charcoal-contrib-sitemap/master/](https://codedoc.pub/locomotivemtl/charcoal-contrib-sitemap/master/index.html)

### Development Dependencies

[](#development-dependencies)

- [php-coveralls/php-coveralls](https://packagist.org/packages/php-coveralls/php-coveralls)
- [phpunit/phpunit](https://packagist.org/packages/phpunit/phpunit)
- [squizlabs/php\_codesniffer](https://packagist.org/packages/squizlabs/php_codesniffer)

### Coding Style

[](#coding-style)

The charcoal-contrib-sitemap module follows the Charcoal coding-style:

- [*PSR-1*](https://www.php-fig.org/psr/psr-1/)
- [*PSR-2*](https://www.php-fig.org/psr/psr-2/)
- [*PSR-4*](https://www.php-fig.org/psr/psr-4/), autoloading is therefore provided by *Composer*.
- [*phpDocumentor*](http://phpdoc.org/) comments.
- [phpcs.xml.dist](phpcs.xml.dist) and [.editorconfig](.editorconfig) for coding standards.

> Coding style validation / enforcement can be performed with `composer phpcs`. An auto-fixer is also available with `composer phpcbf`.

Credits
-------

[](#credits)

- [Locomotive](https://locomotive.ca/)

License
-------

[](#license)

Charcoal is licensed under the MIT license. See [LICENSE](LICENSE) for details.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance59

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 65.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~199 days

Recently: every ~182 days

Total

12

Last Release

705d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a4f39523b4b2837562ba0848a0327b8d340118d1ba87cb0f5d59b1d5cb6beba?d=identicon)[mcaskill](/maintainers/mcaskill)

![](https://www.gravatar.com/avatar/f3f29e38395113e2400bdd7e51bea982b17f120d4d5a53d4473b53118ee46f8d?d=identicon)[JoelAlphonso](/maintainers/JoelAlphonso)

![](https://www.gravatar.com/avatar/4229f19eecd12c2b651b6502dcc5adfba48c5770db3d2dbea55fc92c7a246b2b?d=identicon)[BeneRoch](/maintainers/BeneRoch)

---

Top Contributors

[![mcaskill](https://avatars.githubusercontent.com/u/29353?v=4)](https://github.com/mcaskill "mcaskill (25 commits)")[![BeneRoch](https://avatars.githubusercontent.com/u/3017380?v=4)](https://github.com/BeneRoch "BeneRoch (10 commits)")[![veve40](https://avatars.githubusercontent.com/u/7537381?v=4)](https://github.com/veve40 "veve40 (2 commits)")[![JoelAlphonso](https://avatars.githubusercontent.com/u/10762266?v=4)](https://github.com/JoelAlphonso "JoelAlphonso (1 commits)")

---

Tags

charcoal

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/locomotivemtl-charcoal-contrib-sitemap/health.svg)

```
[![Health](https://phpackages.com/badges/locomotivemtl-charcoal-contrib-sitemap/health.svg)](https://phpackages.com/packages/locomotivemtl-charcoal-contrib-sitemap)
```

###  Alternatives

[locomotivemtl/charcoal-cms

Charcoal CMS (Content Management System) Module

529.0k3](/packages/locomotivemtl-charcoal-cms)[locomotivemtl/charcoal-admin

The Charcoal Administration Dashboard

1110.8k8](/packages/locomotivemtl-charcoal-admin)[locomotivemtl/charcoal-app

Charcoal application, based on Slim 3

1320.3k12](/packages/locomotivemtl-charcoal-app)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
