Newly in v0.155, Page aliases are language-relative instead of absolute to the web root. Assume that I have got the document my-page.de.md, which will be rendered to /de/my-page.
Now I have defined in the frontmatter of my-page.de.md: aliases = [“/page-on-root”, “/en/my-page”]. Both the aliases newly do not work any more as expected and instead create the two new pages /de/page-on-root as well as /de/en/my-page.
How would I now create the aliases I had before?
I have found that aliases = [“../page-on-root”, “../en/my-page”] works - is this the way to go? It doesn’t feel very intuitive to me.
We made a breaking change in v0.155.0 that was not described in the release notes. I apologize for the oversight, and will amend the release notes later today.
With v0.155.0 and later you cannot create an alias to the server root using the aliases feature. Alias paths starting with a slash (/) resolve to the site root, not to the server root.
Perhaps there’s another way to handle your use case; I’ll give it some thought.
This is the setup and objective, as I understand your use case.
baseURL = 'https://example.org/'
defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true
[languages.en]
weight = 1
title = "My Site in English"
[languages.de]
weight = 2
title = "Meine Seite auf Deutsch"
Your MVP looks reasonable to me, though I would also like to have /de/alias-to-p1-en/.
How many aliases do you need to create in the server root?
I would say, about 20. Many of them are links we only keep for backward compatibility and we may just remove them anyways. But there are also some links that are “quick-access” links that we do not want to loose.
Who or what hosts your production site?
We have a pretty basic Debian Server with apache2 (2.4.66) from the official Debian repos.
Since you’re using Apache, assuming mod_alias is active, the most efficient approach is to handle your aliases via server-side redirection. You can have Hugo automatically generate an .htaccess file during the build process to manage this. There’s an example of how to do that with a _redirects file here, which you can modify for the .htaccess format. That example, when modified to create an .htaccess file, should render this:
The last two are server-relative redirects, allowing you to cross content dimension (role, version, language) boundaries.
If for some reason you don’t want to generate an .htaccess file, you can use the data file approach to generate individual 'meta refresh` HTML files. Let me know if you need an example of this.