Using aliases to redirect subdirectory, not working

hi there!

I’m trying to uses the aliases front matter key to redirect an old existing page to a new one, that’s is in a subdirectory.

I want https://mysite.com/contributors/ to redirect to /about/team/
and https://mysite.com/fr/contributors/ to redirect to about /fr/about/team and the same for every language.

This is what I have so far. It’s not working although i’m following the documentation. The weird thing is that if I try to reverse it (/about/team points to /contributors/) it works like a charm!

What’s the problem?
I’ve tried those syntaxes:

aliases: ["/contributors/", "/contributors","contributors" , "contributors/"]

in ./contributors/index.en.md

---
title: Contributors
slug: /contributors/
lang: en
summary: "should redirects to /about/team/"
layout: contributors
---

content

in ./about/team/index.en.md

---
title: "Team"
summary: "My Team"
lang: en
authors: [""]
categories: ["About"]
tags: []
weight: 6
featured_image: "team.jpg"
aliases: ["/contributors/", "/contributors","contributors" , "contributors/"]
layout: team
---

content

It seems like you want xxx to redirect to yyy, but xxx still exists. That won’t work.

https://gohugo.io/content-management/urls/#how-aliases-work

Hugo renders alias files before rendering pages. A new page with the previous file name will overwrite the alias, as expected.

Thank you! So I simply delete /contributors/ and all the files inside it and it solved it.

I have another question: How to redirect a taxonomy page?
I want to redirect /authorsto /about/team/.
I don’t have an index.en.md in my authors folder, yet the redirect doesn’t work.

in about/team/index.en.md

---
title: "Team"
summary: ""
lang: en
authors: [""]
categories: ["About"]
tags: []
weight: 6
featured_image: "team.jpg"
aliases: ["/contributors/", "/about/contributors" , "/authors"]
layout: team
---

in config.toml

[taxonomies]
  author = "authors"
  tag = "tags"
  category = "categories"
  translator = "translators"
  lang = "languages"

content/authors/_index.en.md

+++
title = 'Authors'
date = 2024-02-05T05:34:41-08:00
[_build]
render = 'never'
list = 'never'
+++

Then add an alias to about/team

Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.