Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suffix selector to Output Formats #8897

Open
regisphilibert opened this issue Aug 16, 2021 · 2 comments
Open

Add suffix selector to Output Formats #8897

regisphilibert opened this issue Aug 16, 2021 · 2 comments

Comments

@regisphilibert
Copy link
Member

regisphilibert commented Aug 16, 2021

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...

@github-actions
Copy link

github-actions bot commented Jan 5, 2022

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@github-actions github-actions bot added the Stale label Jan 5, 2022
@bep bep added the Keep label Jan 5, 2022
@github-actions github-actions bot removed the Stale label Jan 6, 2022
@npadgett
Copy link

I'm trying to output both html and htm files to maintain historic URLs. html for new files, htm for old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants