Enable/disable custom output format per language?

I’m using the output formats feature to generate some files but I need them only once. Right now their are being generated in a per language basis. Is there a way to disable the generation in for the non default language?

Thanks!

Maybe a little more context is useful for you guys.

Basically I was trying the http/2 push feature in Netlify in multilingual site (English and Spanish) following this hugo blog post. This is the config:

[outputs]
home = [ "HTML", "HEADERS" ]

[mediaTypes]
[mediaTypes."text/netlify"]
suffix = ""
delimiter = ""

[outputFormats]
[outputFormats.HEADERS]
mediatype = "text/netlify"
baseName = "_headers"
isPlainText = true
notAlternative = true

I wrote my layouts/index.headers file but it is rendered at [output]/_headers and [output]/es/_headers. The header file only makes sense at the root, so I want to it get rendered for the default language only. Is this possible?

Have you tested setting the default to “HTML” only and then [ “HTML”, “HEADERS” ] below the en language.

1 Like

Thank you! :grinning: That worked. I didn’t know that the outputs can be set per language. :sweat_smile:

Can I assume that all the settings can be configured per language then? (Or something similar?).

Almost all. There is a small “blacklist” that will give an error if you try:

var globalOnlySettings = map[string]bool{
	strings.ToLower("defaultContentLanguageInSubdir"): true,
	strings.ToLower("defaultContentLanguage"):         true,
	strings.ToLower("multilingual"):                   true,
	strings.ToLower("assetDir"):                       true,
	strings.ToLower("resourceDir"):                    true,
}
2 Likes

That makes total sense. Thank you very much. :slight_smile: