定制 jorisnoo/craft-sitemap 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jorisnoo/craft-sitemap

Composer 安装命令:

composer require jorisnoo/craft-sitemap

包简介

Zero-config XML sitemap for Craft CMS with multi-site hreflang support.

README 文档

README

A Craft CMS module that generates a zero-config XML sitemap with multi-site hreflang support.

Features

  • Generates a sitemap.xml with all entries and categories that have URIs
  • Adds xhtml:link hreflang alternates for multi-site setups
  • Deduplicates URLs across canonical groups and sites
  • Works with zero config; optional config file to exclude sections, category groups, or URI patterns

Requirements

  • PHP 8.2+
  • Craft CMS 5

Installation

composer require jorisnoo/craft-sitemap

Then register the module in your config/app.php:

return [
    'modules' => [
        'craft-sitemap' => \Noo\CraftSitemap\Module::class,
    ],
    'bootstrap' => ['craft-sitemap'],
];

The sitemap will be available at sitemap.xml on your site.

Configuration

Configuration is optional. To exclude content from the sitemap, create config/craft-sitemap.php:

return [
    // Skip all entries in these section handles
    'excludeSections' => ['private', 'drafts'],

    // Skip all categories in these group handles
    'excludeCategoryGroups' => ['internal'],

    // Skip URIs matching any of these glob patterns (matched against the element URI)
    'excludeUriPatterns' => ['legal/*', 'private'],
];

URI patterns use fnmatch() syntax: * matches any sequence of characters within a path segment, ? matches a single character.

How It Works

The module registers a sitemap.xml route on your site. When requested, it:

  1. Queries all entries and categories with URIs across all sites
  2. Groups elements by their canonical ID to identify translations
  3. Deduplicates by site handle and URL
  4. Renders an XML sitemap with <loc>, <lastmod>, and (on multi-site) <xhtml:link rel="alternate"> tags

Single-site installs get a standard sitemap. Multi-site installs automatically include hreflang alternate links for each translation.

Results are cached and automatically invalidated when entries or categories are saved or deleted.

License

The MIT License (MIT). Please see LICENSE for more information.

统计信息

  • 总下载量: 377
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固