Hi fellow Hugo-ites!
I have a Hugo theme that (among other things) lets users click a button to edit the relevant site page in Github. I build the edit URL in my template using the site’s provided repo name, the page Path, etc.
At the moment I check if there’s a language-specific subdirectory like this:
{{ else if .Site.Language.Lang }}
{{ $editURL = printf “%s/edit/master/content/%s/%s” $gh_repo ($.Site.Language.Lang) .Path }}
However, this is creating the wrong URL for one of my theme users, as their site is not Multilingual, but they do have a specified language (English) for content that is not in an en
subdir:
defaultContentLanguage = “en”
defaultContentLanguageInSubdir = false
If I switch the check to “is this site Multilingual”, however:
{{ else if .Site.IsMultiLingual }}
{{ $editURL = printf “%s/edit/master/content/%s/%s” $gh_repo ($.Site.Language.Lang) .Path }}
…I create the wrong URL for one of my own sites, because it is not Multilingual but does have the content in an en
subdir.
defaultContentLanguage = “en”
defaultContentLanguageInSubdir = true
Is there a nice Hugo way of checking in a template whether defaultContentLanguageInSubdir
is true, given that it isn’t a parameter?
Thanks for any help!