Files
hugo/resources
Rodrigo Ipince 39507d51bf resources/page: Don't let a title's "/" split an auto-derived slug
When a page has no explicit slug, the :title and :slug permalink tokens
fall back to a URL-safe form of the title. That sanitization step
(PathSpec.URLize / MakePathSanitized) intentionally treats "/" as a
valid path character, since it is also used for things like taxonomy
term names that legitimately span multiple path segments.

For a regular content page, though, the auto-derived slug is meant to
be a single path segment (the front matter "slug" field docs say it
"overrides the last segment of the URL path"). A title containing a
literal "/", e.g. "Watch/listen to this", was passed straight through
into the permalink pattern, silently creating an extra nested path
segment (.../watch/listen-to-this/) instead of a single sanitized one
(.../watch-listen-to-this/). No warning or error was produced; the
site just built with an unintended URL structure.

This behavior regressed from a fix already applied once via #4092 and
#5282 (which used a stricter helpers.PathSpec.MakeSegment for titles,
exempting only taxonomy pages). That distinction was lost when slash
handling in taxonomy terms was restored for #5571, which switched
title handling back to the slash-preserving URLize function for all
page kinds, not just taxonomies.

Restore the taxonomy/term exemption: pageToPermalinkTitle now replaces
"/" (and "\") with "-" before urlizing the title, but only for page
kinds other than taxonomy and term, so multi-level taxonomy
hierarchies (the behavior #5571 asked for) keep working exactly as
before. Explicit "slug" front matter values are untouched by this
change, since users should stay in full control of an explicitly set
slug.

Fixes #3577
See #5571
See #4090
2026-08-31 11:06:30 +02:00
..
2026-08-20 20:23:18 +02:00
2026-06-07 21:20:40 +02:00
2026-08-20 20:23:18 +02:00
2025-11-05 21:05:42 +01:00