Skip to content

Add suffix selector to Output Formats #8897

@regisphilibert

Description

@regisphilibert

The problem

While this is possible and recommended to define any mediaType's extensions as an array of suffixes, it is not currently possible to choose which suffix to use when generating a file from an output format.

To clarify, if I...

  1. add the rss suffix to the built-in application/rss+xml media
  2. and use this media type on custom output format
# 1
mediaTypes:
  application/rss+xml:
    suffixes:
    - xml
    - rss

# 2
outputFormats:
  rss_feed:
    mediaType: application/rss+xml
    baseName: feed

The rss_feed output format will generate a feed.xml file, using the first suffix.

Even though several suffixes are declared on the media type, it is impossible to choose one when assigning it to an output format.

proposed solution 1 (as suggested here)

Adding a suffix key to the outputFormat.

If set, Hugo would use the given suffix when generating the file.
If not set, current behaviour prevails, it would use the first suffix.

# 2
outputFormats:
  rss_feed:
    mediaType: application/rss+xml
    baseName: feed
    suffix: rss

Would generate /feed.rss

proposed solution 2

Use the extension of the template file if matching any of the mediaType suffixes.

if index.rss_feed.rss is found, this means the file should be generated at feed.rss
if index.rss_feed.xml is found, this means the file should be generated at feed.xml

If both files are found, first suffix of the set output format should be used or both files could be created...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions