Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't set relative aliases for home page #13346

Open
BrianLeishman opened this issue Feb 4, 2025 · 7 comments
Open

Can't set relative aliases for home page #13346

BrianLeishman opened this issue Feb 4, 2025 · 7 comments
Labels
Milestone

Comments

@BrianLeishman
Copy link

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.143.0-DEV-13b208e2f70fd0bfad8a4ae33a30afb5fd4b7477+extended linux/amd64 BuildDate=2025-01-31T08:29:10Z

Does this issue reproduce with the latest release?

Yes


Related issue about multi language sites and relative aliases here: #5757

I have a multi language site where I am trying to set the alias of a home page in the front matter like so:

---
title: Welcome to our cool website!
layout: single

aliases:
  - welcome
---

# My cool website

And while this works page bundle pages correctly (it's relative to the "parent" directory of the (_)index file), this seems to be causing this bug on the root/site home page, throwing this error:

render: alias "../welcome" traverses outside the website root directory

@jmooring
Copy link
Member

jmooring commented Feb 6, 2025

I am unable to reproduce the problem as described:

git clone --single-branch -b hugo-github-issue-13346 https://github.com/jmooring/hugo-testing hugo-github-issue-13346
cd hugo-github-issue-13346
hugo server

So there must be something different about your site.

@BrianLeishman
Copy link
Author

Just reworked that test to match our setup:

https://github.com/BrianLeishman/hugo-testing/tree/hugo-github-issue-13346

I'm using the content mounts to handle "default" files for the other language, but I feel like the defaultContentLanguageInSubdir is more likely the culprit, as we need that off

@jmooring
Copy link
Member

jmooring commented Feb 6, 2025

I can reproduce the behavior by setting defaultContentLanguageInSubdir = false.

For now, set your aliases like this:

aliases = ['/en/welcome']
aliases = ['/de/willkommen']

@BrianLeishman
Copy link
Author

I have a different workaround at the moment, just a "home-redirects" file with it's own aliases that redirects to the index page haha, but we don't have the other language contents yet for the index page, just some other pages like our contact page.

@jmooring
Copy link
Member

jmooring commented Feb 6, 2025

This issue is not specific to multilingual sites. You cannot a create an alias for the home page with a relative path. I'm not sure whether this is a bug or an ennhacement.

@bep bep added this to the v0.144.0 milestone Feb 6, 2025
@bep
Copy link
Member

bep commented Feb 6, 2025

this is a bug or an ennhacement.

Smells like a bug to me, but I haven't thought about aliasing the home page being useful.

@BrianLeishman
Copy link
Author

Use case to us is that this is a new website replacing a very old version, huge site overhaul. But the old site had a bunch of landing pages that didn't make sense anymore, and our home page is kind of the starting point to browsing our site in the new user experience.

So all those old links now route to home.

@bep bep modified the milestones: v0.144.0, Unscheduled Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants