Here is the config that I have tried so far. Yet, defining languagePrefix in config.yaml does not appear to change the URL which stays with ‘en’ and ‘gr’. The {{ .Site.LanguagePrefix }} markup also does not change.
languages:
en:
title: My New Hugo i18n Site
languageCode: en
languagePrefix: english
weight: 1
gr:
title: My New Hugo i18n Site Greek Edition
languageCode: gr
languagePrefix: greek
weight: 2
I am not sure I get your question… in your sample config it states languagePrefix: greek - isn’t that what you want to know? Change it into “blarg” and the url will start with “blarg”?
You will have to post a link to a minimal demo repository so we can see what the issue is. I have the feeling you have another issue if the links don’t come out as expected.
My question is “can this variable be defined in the config, or is it a read-only variable defined by Hugo?”
The sample config is fine by me. The problem is that when I define this parameter in the config like in the example, it is not taken into consideration by Hugo while writing the URL.
First of all: I assumed you showed a config that is not “thought up” by yourself So languagePrefix is not a configuration parameter of Hugo? Then no, it won’t work.
From the code you posted it appears that Hugo is taking the “en” or “gr” as languagePrefix. I read in the docs (can’t find it now, sorry) that you can name your languages any way you want. So try renaming the gr in your sample config into blarg. I would expect it to show up as URL-slug.
If not - this is something I would think of as a nice-to-have feature. Maybe consider opening a feature request in Hugo’s Github repo.