Skip to content

Improve .Page.Aliases to support multiple output formats #14467

@jmooring

Description

@jmooring

I ran into this while documenting the changes to .Page.Aliases. Consider this site config:

[mediaTypes]
  [mediaTypes.'text/redirects']
    delimiter = ''

[outputFormats]
  [outputFormats.print]
    isHTML        = true
    mediaType     = 'text/html'
    path          = 'print'
    permalinkable = true
  [outputFormats.redirects]
    baseName    = '_redirects'
    isPlainText = true
    mediaType   = 'text/redirects'
    root        = true

[outputs]
  home    = ['html', 'redirects']
  page    = ['html', 'print']
  section = ['html', 'print']

When building the site we create the meta-refresh alias files for both the html and print output formats, as expected.

But in the example below, the _redirects file only includes redirects for the html output format:

git clone --single-branch -b hugo-github-issue-14388 https://github.com/jmooring/hugo-testing hugo-github-issue-14388
cd hugo-github-issue-14388
rm -rf public && hugo && tree public && cat public/_redirects

Maybe there's already a way to do this, but it eludes me at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions