PHPackages                             groe/craft-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. groe/craft-sitemap

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

groe/craft-sitemap
==================

Craft plugin to generate a sitemap.

v1.2.3(8y ago)231.1k8[2 PRs](https://github.com/groe/craft-sitemap/pulls)MPL 2.0PHP

Since May 11Pushed 7y ago2 watchersCompare

[ Source](https://github.com/groe/craft-sitemap)[ Packagist](https://packagist.org/packages/groe/craft-sitemap)[ RSS](/packages/groe-craft-sitemap/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

**NOTE: This is a fork of the currently unmaintained [craft-sitemap plugin by @joshuabaker](https://github.com/joshuabaker/craft-sitemap).**The original author has not responded to [questions regarding his plans for the future of the project](https://github.com/joshuabaker/craft-sitemap/issues/28). So feel free to use the fork while we (hopefully) merge it back some day.

Craft Sitemap
=============

[](#craft-sitemap)

A simple plugin for [Craft](http://craftcms.com) that generates a [sitemap.xml](http://www.sitemaps.org/) based on enabled sections.

[![Settings](https://camo.githubusercontent.com/bd2fd133d9c5803c56d27e6d884d73ac37d27d1e93951c7524fbc866543364b4/687474703a2f2f692e696d6775722e636f6d2f446858546e32662e6a7067)](https://camo.githubusercontent.com/bd2fd133d9c5803c56d27e6d884d73ac37d27d1e93951c7524fbc866543364b4/687474703a2f2f692e696d6775722e636f6d2f446858546e32662e6a7067)

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

[](#installation)

1. Copy the `sitemap/` folder into `craft/plugins/`
2. Go to Settings → Plugins and click the “Install” button next to “Sitemap”

Usage
-----

[](#usage)

Within the plugin settings, check the boxes in the “Enabled” column to include them in the sitemap.

To view the output visit `/sitemap.xml`.

Advanced
--------

[](#advanced)

This plugin exposes various [service methods](#service-methods), which can be used to add custom items to the sitemap through the [`renderSitemap` hook](#rendersitemap). Please read the official [‘Hooks and Events’ documentation](http://buildwithcraft.com/docs/plugins/hooks-and-events), if you’re not sure how this works.

### Hooks

[](#hooks)

##### `renderSitemap`

[](#rendersitemap)

Add a `renderSitemap` method to your plugin to add items via the various [service methods](#service-methods) listed below.

Here’s an example plugin hook method with comments:

```
public function renderSitemap()
{
    // Get an ElementCriteriaModel from the ElementsService
    $criteria = craft()->elements->getCriteria(ElementType::Entry);

    // Specify that we want entries within the ‘locations’ section
    $criteria->section = 'locations';

    // Loop through any entries that were found
    foreach ($criteria->find() as $locationEntry)
    {
        // Here we’re building a path using the entry slug.
        // This might match a custom route you’ve defined that
        // should be included in the sitemap.
        $path = 'cars-for-sale-in-' . $locationEntry->slug;

        // Make sure that we’re using a full URL, not just the path.
        $url = UrlHelper::getSiteUrl($path);

        // For the sake of this example, we’re setting the $lastmod
        // value to the most recent time the location entry was
        // updated. You can pass any time using the DateTime class.
        $lastmod = $locationEntry->dateUpdated;

        // Add the URL to the sitemap
        craft()->sitemap->addUrl($url, $lastmod, Sitemap_ChangeFrequency::Daily, 0.5);
    }
}
```

And here’s an example of the resulting element in the sitemap XML:

```

  http://example.com/cars-for-sale-in-scotland
  2015-08-28T15:08:28+00:00

```

### Service Methods

[](#service-methods)

There’s several service methods made available to add items to the sitemap.

##### `addUrl($loc, $lastmod, [$changefreq, [$priority]])`

[](#addurlloc-lastmod-changefreq-priority)

Adds a URL to the sitemap.

```
$loc = UrlHelper::getSiteUrl('special/route');
$lastmod = new DateTime('now');
craft()->sitemap->addUrl($loc, $lastmod, Sitemap_ChangeFrequency::Yearly, 0.1);
```

##### `addElement(BaseElementModel $element, [$changefreq, [$priority, [$currentLocaleOnly, [$alternateUrls]]]])`

[](#addelementbaseelementmodel-element-changefreq-priority-currentlocaleonly-alternateurls)

Adds an element to the sitemap.

```
$element = craft()->elements->getElementById(2);
craft()->sitemap->addElement($element, Sitemap_ChangeFrequency::Daily, 1.0);
```

##### `addSection(SectionModel $section, [$changefreq, [$priority, [$currentLocaleOnly, [$alternateUrls]]]])`

[](#addsectionsectionmodel-section-changefreq-priority-currentlocaleonly-alternateurls)

Adds all entries in the section to the sitemap.

```
$section = craft()->sections->getSectionByHandle('homepage');
craft()->sitemap->addSection($section, Sitemap_ChangeFrequency::Weekly, 1.0);
```

##### `addCategoryGroup(CategoryGroupModel $categoryGroup, [$changefreq, [$priority, [$currentLocaleOnly, [$alternateUrls]]]])`

[](#addcategorygroupcategorygroupmodel-categorygroup-changefreq-priority-currentlocaleonly-alternateurls)

Adds all categories in the group to the sitemap.

```
$group = craft()->categories->getGroupByHandle('news');
craft()->sitemap->addCategoryGroup($group);
```

##### `getElementUrlForLocale(BaseElementModel $element, $locale)`

[](#getelementurlforlocalebaseelementmodel-element-locale)

Gets a element URL for the specified locale. The locale must be enabled.

```
echo $element->url;
// http://example.com/en/hello-world

echo craft()->sitemap->getElementUrlForLocale($element, 'fr');
// http://example.com/fr/bonjour-monde
```

##### `getUrlForLocale($path, $locale)`

[](#geturlforlocalepath-locale)

Gets a URL for the specified locale. The locale must be enabled.

```
echo UrlHelper::getSiteUrl('foo/bar');
// http://example.com/en/foo/bar

echo craft()->sitemap->getUrlForLocale('foo/bar', 'fr');
// http://example.com/fr/foo/bar
```

#### Helper Classes

[](#helper-classes)

##### `Sitemap_ChangeFrequency`

[](#sitemap_changefrequency)

Enumeration of valid `changefreq` values.

```
Sitemap_ChangeFrequency::Always
Sitemap_ChangeFrequency::Hourly
Sitemap_ChangeFrequency::Daily
Sitemap_ChangeFrequency::Weekly
Sitemap_ChangeFrequency::Monthly
Sitemap_ChangeFrequency::Yearly
Sitemap_ChangeFrequency::Never
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 84.4% 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 ~85 days

Total

5

Last Release

2995d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13695024?v=4)[mcacace](/maintainers/mcacace)[@mcacace](https://github.com/mcacace)

---

Top Contributors

[![joshuabaker](https://avatars.githubusercontent.com/u/160484?v=4)](https://github.com/joshuabaker "joshuabaker (81 commits)")[![groe](https://avatars.githubusercontent.com/u/515293?v=4)](https://github.com/groe "groe (5 commits)")[![jamesmacwhite](https://avatars.githubusercontent.com/u/8067792?v=4)](https://github.com/jamesmacwhite "jamesmacwhite (1 commits)")[![johandouma](https://avatars.githubusercontent.com/u/9311?v=4)](https://github.com/johandouma "johandouma (1 commits)")[![Ksealey1990](https://avatars.githubusercontent.com/u/5154895?v=4)](https://github.com/Ksealey1990 "Ksealey1990 (1 commits)")[![lboaretto](https://avatars.githubusercontent.com/u/35883?v=4)](https://github.com/lboaretto "lboaretto (1 commits)")[![mike27cubes](https://avatars.githubusercontent.com/u/204885?v=4)](https://github.com/mike27cubes "mike27cubes (1 commits)")[![rubenwebs](https://avatars.githubusercontent.com/u/5013717?v=4)](https://github.com/rubenwebs "rubenwebs (1 commits)")[![tcsehv](https://avatars.githubusercontent.com/u/2689733?v=4)](https://github.com/tcsehv "tcsehv (1 commits)")[![elivz](https://avatars.githubusercontent.com/u/62592?v=4)](https://github.com/elivz "elivz (1 commits)")[![zauni](https://avatars.githubusercontent.com/u/663845?v=4)](https://github.com/zauni "zauni (1 commits)")[![emcacace](https://avatars.githubusercontent.com/u/3730391?v=4)](https://github.com/emcacace "emcacace (1 commits)")

---

Tags

craftcmscraftcms-pluginseo

### Embed Badge

![Health badge](/badges/groe-craft-sitemap/health.svg)

```
[![Health](https://phpackages.com/badges/groe-craft-sitemap/health.svg)](https://phpackages.com/packages/groe-craft-sitemap)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[mautic/core

Mautic Open Source Distribution

9.8k2.6k9](/packages/mautic-core)[mediawiki/maps

Adds various mapping features to MediaWiki

78149.7k3](/packages/mediawiki-maps)[rainlab/blog-plugin

Blog plugin for October CMS

17158.6k](/packages/rainlab-blog-plugin)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

19246.3k2](/packages/civicrm-civicrm-drupal-8)[starcitizentools/citizen-skin

A beautiful, usable, responsive MediaWiki skin with in-depth extension support. Originally developed for the Star Citizen Wiki.

3355.8k](/packages/starcitizentools-citizen-skin)

PHPackages © 2026

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