Category-based HTML sitemap pages with efficient caching and a bundled template.
- WordPress with pretty permalinks enabled
- Plugin activated in
wp-content/plugins/html-sitemap-categorized
- Place the plugin in
wp-content/plugins/html-sitemap-categorized
. - Activate “HTML Sitemap Categorized” in wp-admin → Plugins.
- Flush permalinks (see below).
To install the plugin via Composer, follow these steps:
-
Add the Repository:
-
Open your project's
composer.json
file. -
Add the following under the
repositories
section:"repositories": [ { "type": "vcs", "url": "https://github.com/xwp/html-sitemap-categorized" } ]
-
-
Require the Plugin:
-
Run the following command in your terminal:
composer require xwp/html-sitemap-categorized
-
-
Activate the Plugin:
- Once installed, activate the plugin through the 'Plugins' menu in WordPress.
- Create a new Page in wp-admin → Pages:
- Title: Sitemap (or any title you prefer)
- Permalink/Slug:
sitemap
- Publish the page
- Flush permalinks:
- Go to wp-admin → Settings → Permalinks → click “Save Changes”.
- Visit
/sitemap/
to see the sitemap index. - Category pages are available at
/sitemap/<category-slug>-<page>/
(e.g.,/sitemap/news-1/
).
Notes:
- The plugin forces its own template for
/sitemap/
and matching category URLs. - Breadcrumbs and pagination render automatically on category pages.
If /sitemap/
returns a 404 or does not use the sitemap template, flush permalinks:
- wp-admin → Settings → Permalinks → Save Changes
Uses WordPress object cache (wp_cache_get
/wp_cache_set
) with group html_sitemap
:
- Category meta (counts/pages): ~24 hours
- Root sitemap HTML: ~6 hours
- Category page HTML: ~15 days
Automatic invalidation/regeneration on post save/status changes:
- Refreshes category meta
- Rebuilds the newest category sitemap page HTML
- Clears the root/index cache
To force a rebuild:
- Flush the object cache (e.g.,
wp cache flush
) or clear entries in thehtml_sitemap
group bywp cache flush-group html-sitemap
.
- Schedules single events on
html_sitemap_regenerate_category
after post changes. - On plugin deactivation, scheduled jobs for this hook are cleared.
For sitemap requests, the plugin sends:
Cache-Control
withs-maxage
,stale-while-revalidate
, andstale-if-error
Surrogate-Key
headers (sitemap-index
andsitemap-cat-<slug>
) for targeted CDN purges
- Stylesheet is loaded only for sitemap URLs:
assets/sitemap-html.css
(handle:html-sitemap-categorized
). - Customize by adding theme styles or dequeuing the handle and enqueuing your own stylesheet.
- 404 on
/sitemap/
or category URLs: flush permalinks. - Empty sitemap: ensure the Sitemap page exists (slug
sitemap
) and you have published posts with categories. - Styles not applied: ensure the plugin is active and the
html-sitemap-categorized
style is not dequeued.
- Deactivation clears scheduled regeneration cron events.
- Cached entries in the
html_sitemap
group expire naturally or can be flushed.