Output formats with Basename and URL parameter

Hugo is not building URLs for a custom output format when the URL parameter is set in the pages frontmatter.

Front matter settings:

url: 2020.html
    - html
    - gridview

Output settings:

        mediaType = "text/html"
        baseName = "gridview" # Does not seem to work if page us URL set manually in frontmatter
        isPlainText = false
        isHtml = true
        noUgly = true
        permalinkable = true


{alternate {gridview text/html gridview alternate false true true false true 0} /2020.html http://localhost:1313/2020.html}

For other pages that do not have a URL parameter set the output returns permalink/gridview.html as expected.

Is this by design? Is this a bug? Or is there something I’m doing wrong?


the doc has no blanks infront of the formats

date: "2016-03-19"
- html
- amp
- json


Tabbing here in the frontmatter is not an issue, and can confirm that this tabbing format does work on a content page without the URL parameter being set.

OK, should read it correct :wink:

Hugo can not generate different outputs in the same file.

Define a new mediaformat for gridview with a different suffix

    suffixes               = ["htm"]

        mediaType = "text/html-grid"

Yes, if you set url then that URL is the one used as URL.

1 Like

Thanks for the response @bep. Any plans in expanding on this functionality? Not a problem to change some of the content structure, just wanted to try this as a solution. Unless I missed it, I would suggested updating the documents to note that the URL param will override other settings such as output format.

Keep up the great work!

I may have misread your initial post, but the URL overrides the URL, not the output format …?

In my most simplest understanding, when a URL parameter is set on a page, it overrides the baseName of a custom output format.

I’ve tested a few pages with and without URL present, and it seems to be the issue. However, the path setting in output format still works as expected when URL is set.

Hope that makes sense.

My memory is a little hazy, but the above kind of makes sense. The url front matter has always been a way to tell Hugo to use this as the URL instead of the permalinks and output format config etc. But you still get the other side effects of defining a output format.

1 Like

@bep some ideas …


  • replacing mediaType with a suffix param?
    mediaType can be found via suffix, must be in suffixes too
    suffix can overwrite the URL suffix
    Can it used to find the right template ??

would be much clear to use

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.