Skip to content

Bug: 'series' taxonomy lookup fails for multi-word names with spaces (e.g., "Some Series Name with Spaces") #980

@TheGlacius

Description

@TheGlacius

Describe the problem:

The series taxonomy, when assigned multi-word names with spaces in post front matter (e.g., series = ['Some Series Name with Spaces']), is not correctly recognized and grouped by the theme's posts/series.html partial.

Steps to reproduce:

  1. Ensure series taxonomy is enabled in config.toml.
  2. Create at least two (or more) posts that belong to the same series, using a multi-word name with spaces in the front matter.
  3. Run Hugo locally.
  4. Navigate to one of the single post pages that belongs to the series.

Observed Results:

  • What happened?
    The "See also in [Series Name]" section, which is rendered by layouts/partials/posts/series.html, does not appear on the single post page.

  • What did you expect to happen?
    I expected a section titled "See also in [Series Name]" (or similar) to appear, listing the other posts in that series, as defined by the series front matter.

Relevant code exceptions or logs

Hugo Version: v0.148.1+extended windows/amd64

When layouts/partials/posts/series.html used the original problematic code (simplified debug output):

DEBUG: Current Page URL: /posts/some-post-in-series/
DEBUG: Series parameters for this page: Some Series Name with Spaces
DEBUG: Raw Series Name from Front Matter: "Some Series Name with Spaces"
DEBUG: Anchorized Name (used for lookup): "some-series-name-with-spaces"
DEBUG: Is $seriesPagesCollection found for slug "some-series-name-with-spaces"? NO
DEBUG: Number of pages in this series collection (some-series-name-with-spaces): 0
DEBUG: Pages in this series (Titles):
DEBUG: CONDITION NOT MET: (len $seriesPagesCollection) > 1 is FALSE. Only 0 pages found.

When a diagnostic debug was added to list all series keys Hugo recognizes ($.Site.Taxonomies.series):

DEBUG: Taxonomy Diagnostic Check
Current Page URL: /posts/some-post-in-series/

DEBUG: Does this page have `series` in its front matter? YES (Value: Some Series Name with Spaces)

DEBUG: All Series Keys Hugo Sees in `$.Site.Taxonomies.series`:
**Key: "some series name with spaces"** (Number of Pages: 2)
- First Post in Some Series
- Second Post in Some Series

Analysis:

The issue appears to be a mismatch between the slug generated by | anchorize (which is some-series-name-with-spaces) and the actual key Hugo uses internally for series taxonomy terms with spaces (which is some series name with spaces - lowercase with spaces).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions