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.5(2mo ago)01.8k1MITPHPPHP &gt;=5.6.0 || &gt;=7.0

Since Jun 1Pushed 2mo 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 today

READMEChangelog (10)Dependencies (18)Versions (15)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)

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)
- [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 7.4+](https://php.net)**
- **[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": {}
}
```

Also add the necessary JS to allow sitemap generation from the back-end interface:

```
    "assets": {
        "collections": {
            "js": {
                "files": [
                    "vendor/locomotivemtl/charcoal-contrib-sitemap/assets/scripts/contrib-sitemap.js"
                ]
            }
        }
    }
```

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.

You can generate a `sitemap.xml` file with the script `vendor/bin/charcoal sitemap/generate` and the admin action `admin/sitemap/generate`. It is recommanded to add a cron job to regenerate the file to avoid outdated sitemap.xml file.

Credits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance86

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.1% 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 ~240 days

Recently: every ~298 days

Total

13

Last Release

67d 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 (11 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.1k3](/packages/locomotivemtl-charcoal-cms)[locomotivemtl/charcoal-admin

The Charcoal Administration Dashboard

1110.9k12](/packages/locomotivemtl-charcoal-admin)[locomotivemtl/charcoal-app

Charcoal application, based on Slim 3

1320.4k13](/packages/locomotivemtl-charcoal-app)

PHPackages © 2026

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