All Projects → craft-plugins → Craft Sitemap

craft-plugins / Craft Sitemap

Licence: mpl-2.0
Craft plugin to generate a sitemap.

Projects that are alternatives of or similar to Craft Sitemap

Seo
SEO utilities including a unique field type, sitemap & redirect manager
Stars: ✭ 210 (+100%)
Mutual labels:  craft-plugin, sitemap, craft, seo
Craft Seomatic
SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
Stars: ✭ 135 (+28.57%)
Mutual labels:  craft-plugin, sitemap, seo
Laravel Seo Tools
Laravel Seo package for Content writer/admin/web master who do not know programming but want to edit/update SEO tags from dashboard
Stars: ✭ 99 (-5.71%)
Mutual labels:  sitemap, seo
Sitemap Generator
Easily create XML sitemaps for your website.
Stars: ✭ 273 (+160%)
Mutual labels:  sitemap, seo
Craft Preparse Field
Field type that parses twig when an element is saved.
Stars: ✭ 103 (-1.9%)
Mutual labels:  craft-plugin, craft
Craft.patrol
Patrol simplifies SSL and maintenance routing for sites built with Craft
Stars: ✭ 91 (-13.33%)
Mutual labels:  craft-plugin, craft
craft-entriessubset
Craft field type plugin that extends the core Entries field type to give extra settings
Stars: ✭ 27 (-74.29%)
Mutual labels:  craft, craft-plugin
Next Sitemap
Sitemap generator for next.js. Generate sitemap(s) and robots.txt for all static/pre-rendered/dynamic/server-side pages.
Stars: ✭ 426 (+305.71%)
Mutual labels:  sitemap, seo
picpuller-for-craft3
Pic Puller for Craft 3 lets authorized users pull in their Instagram media into Craft.
Stars: ✭ 12 (-88.57%)
Mutual labels:  craft, craft-plugin
Craft Brief
Quick, easy, and customizable user-group notifications for Craft CMS.
Stars: ✭ 47 (-55.24%)
Mutual labels:  craft-plugin, craft
Sitemap Module
Sitemap Module for Nuxt
Stars: ✭ 539 (+413.33%)
Mutual labels:  sitemap, seo
Buttonbox
A collection of utility field types for Craft
Stars: ✭ 94 (-10.48%)
Mutual labels:  craft-plugin, craft
craft-plugin-mix
Helper plugin for Laravel Mix in Craft CMS templates
Stars: ✭ 50 (-52.38%)
Mutual labels:  craft, craft-plugin
sitemap
A simple sitemap generator for Laravel Framework.
Stars: ✭ 32 (-69.52%)
Mutual labels:  sitemap, seo
strapi-plugin-sitemap
🔌 Generate a highly customizable sitemap XML in Strapi CMS
Stars: ✭ 136 (+29.52%)
Mutual labels:  sitemap, seo
craft-instagram-feed
Craft CMS plugin to receive Instragram feed data as variable in templates
Stars: ✭ 25 (-76.19%)
Mutual labels:  craft, craft-plugin
Seomatic
DEPRECATED A turnkey SEO implementation for Craft CMS 2.x that is comprehensive, powerful, and flexible
Stars: ✭ 366 (+248.57%)
Mutual labels:  craft-plugin, seo
Laravel Sitemap
Create and generate sitemaps with ease
Stars: ✭ 1,325 (+1161.9%)
Mutual labels:  sitemap, seo
sitemap-checker
a tool for validate xml sitemap and sitemap index files for broken links
Stars: ✭ 21 (-80%)
Mutual labels:  sitemap, seo
craft3-seeder
Seeder is the easiest way to quickly create placeholder content while you're building out a website. Create your sections & fields and then let Seeder make entries for you.
Stars: ✭ 30 (-71.43%)
Mutual labels:  craft, craft-plugin

Craft Sitemap

A simple plugin for Craft that generates a sitemap.xml based on enabled sections.

Settings

Installation

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

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

This plugin exposes various service methods, which can be used to add custom items to the sitemap through the renderSitemap hook. Please read the official ‘Hooks and Events’ documentation, if you’re not sure how this works.

Hooks

renderSitemap

Add a renderSitemap method to your plugin to add items via the various 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:

<url>
  <loc>http://example.com/cars-for-sale-in-scotland</loc>
  <lastmod>2015-08-28T15:08:28+00:00</lastmod>
</url>

Service Methods

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

addUrl($loc, $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]])

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]])

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]])

Adds all categories in the group to the sitemap.

$group = craft()->categories->getGroupByHandle('news');
craft()->sitemap->addCategoryGroup($group);
getElementUrlForLocale(BaseElementModel $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)

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

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].