Solvedhugo Override section url

Hi all,

I'm building a multilingual site and would like to have 2 different urls for my section list page.

The content is as follows:

content
|___product
|___ _index.md
|___ product-1.md
|___ product-1.fr.md

Currently, by default, hugo generates /product and /product/product-1 which is expected.

For multilingual purpose, I want to achieve:
English:

/product
/product/product-1

French:

/produit
/produit/produit-1

I can achieve /produit/produit-1 by permalinks configuration in config.toml but I don't know how to generate /produit one which will still use my section template page under theme/layouts/section/product.html (same for both language).

Any idea would be very appreciated.

Thanks a lot.

P/S: I tried with putting url and slug in _index.md and that seems not working although the content of the file is picked up correctly in the template.

This is issue is referenced by this discussion.

25 Answers

✔️Accepted Answer

Just thought I'd chime in and say that this is my single biggest issue using Hugo at the moment, and I think probably the only major roadblock to really powerful multilingual sites.

In my case, I have for example a notes section. In English, I want that section to have the title "Notes", the list page to appear at http://example.com/notes/, and the pages to be at eg. http://example.com/notes/on-making-a-website.html.

But, in Japanese, I need that section to have the title 意見 (iken), the list page to appear at http://example.com/ja/iken/ and the pages to be at eg. http://example.com/ja/iken/saito-wo-tukuru.html.

At the moment, I can get the subpages to have the correct output path (http://example.com/ja/iken/saito-wo-tukuru.html), by using

Languages:
  ja:
      permalinks:
        notes: /iken/:slug

in my config.yaml, but the list page permalink will still come out at http://example.com/ja/notes/.

Even using rewrite rules on Netlify, and throwing some hack-y code into templates and shortlinks using a Param listing these problem sections (ie. index .Site.Params.slugPatches (.Get 0)), I still can't get the permalinks in .Translations to match up.

It means I can't have a URL that makes sense in the target language, and there's no possible workaround that I can find.

On the other hand, if the section's output folder was named after the slug value in the section's frontmatter, just like for single pages, the system would work perfectly (and make a lot of immediate sense). Sections could be correctly translated, and the pages in the sections would have a correctly translated path.

Then, in /content/notes/_index.ja.md I could just put

---
title: 意見
slug: iken
---

instead of all those workarounds/.Site.Params/redirect rules.

Other Answers:

@regisphilibert thank you for the example. But sadly this still does not work for sub-sections or scales for multiple sections (as @jonjbar pointed out). The user experience I'd like to see, or I think this thread here is looking for, is described here. In short, it's something around the lines of, the ability to overwrite slug (meaning the part of the url for its specific path level) in its corresponding _index.[$Lang].md front matter.

any news on this?

I have the same issue now, trying to switch to hugo for an existing site. The concept of _index.[lang].md files for sections is great, and it's one of the biggest issues.

Without a doubt, all contributors do an amazing work and I am very thankful for all their effort. I was just citing his own words, which, at least to me, seems to show a bit of an inappropriate attitude in that context.

Regarding .34, I couldn't find any hint of this issue being solved in the release. I already installed the latest release and noticed no difference in the behaviour already described.

Related Issues:

16
hugo Add a base set of resource filters/processors
re: @budparr I find tools like PurgeCSS or PurifyCSS—which remove unused CSS—pretty valuable ...
14
hugo The big assets handling / resource transformation funcs naming thread
This looks mighty cool but how about using a shorter namespace than resources? Like asset ...
13
hugo Override section url
Just thought I'd chime in and say that this is my single biggest issue using Hugo at the moment ...
12
hugo Add image processing support for WebP image resources
webp is currently not supported I guess that is probably not crystal clear in the documentation and ...
716
jekyll Jekyll serve fails on Ruby 3.0
I think you want bundle add webrick. My Environment Software Version(s) Operating System Ubuntu 20.0...
88
vuepress Fix babel useBuiltIns core-js warning
Adding corejs: 3.0.0 in the .babelrc file turned off the warnings. I confirm that this is an issue r...
86
jekyll Cannot install Jekyll on MacOS Mojave
I cannot I used Jekyll on my MacBook Pro without any problem in the previous version of MacOS I upda...
57
jekyll unable to build a jekyll site … invalid date
I've solved it! It seems that you need to place the line exclude: [vendor] in _config.yml found this...
56
vuepress vuepress dev: throws res.getHeader() is not a function
The dependency chain is webpack-serve -> koa-webpack -> webpack-dev-middleware and it's caused by th...
45
jekyll Jekyll 4.0 Ideas
Please please support for i18n At least 2 languages Many plug-ins break or don't work with ghpages. ...
45
vuepress Blog Support roadmap (Resolved)
RSS/JSON Feed Draft post Ability to eliminates the .html extension Split date into subdirs: blog/201...
36
vuepress Hot reload not working
watchpack: 1.6.1 I noticed that the webpack hot update plugin watchpack is now 1.7.2 I compared the ...
36
vuepress Option to automatically list sub-directory in the sidebar
I like this idea too To be honest that's what I expected to happen I've got a docs/components folder...
22
eleventy Slug filter doesn't create url safe slugs.
yup @zachleat it does replace the slug so I just do remove some chars to make it little bit prettier...
22
vuepress Automatic Reload not working?
I got it working by downgrading dependency watchpack to 1.6.1 Added resolutions section to package.j...
20
eleventy Official Asset Pipeline
I've been using a stylesheet.11ty.js template file to compile CSS (via postcss in my case) I have an...
18
vuepress Unknown Custom Element - <v-#####>
@davision A quick fix for this issue in enhanceApp.js (for 1.0.0-alpha.42): This will (I think) fix ...
16
jekyll bundler: failed to load command: jekyll
Found this previous issue - ffi/ffi#368 The following fixed my problem: Got it working now! For thos...
15
eleventy How to create sitemap.xml?
Hi @rolandtoth I’ve created one for my (yet un-launched) site You can use the following template (th...
14
eleventy Eleventy reusable components shortcode
Thanks for thinking out loud here this is super helpful feedback to see what you’re trying to do May...
13
jekyll jekyll install leads to immediate errors
Something that's not clearly stated in our docs: Running Jekyll commands with recent versions ...
13
wowchemy hugo themes TOC for blog posts
@CarlosVecina Change the file <root dir>/layouts/_default/single.html as follows: and add the follow...
12
vuepress [Proposal] Plugin API
I actually prefer a simple object-based API as @ycmjason suggested Background Hey guys ...
11
vuepress Has anyone gotten mermaid working?
This is how I got it working on mermaid v7.1.2 and vuepress v0.14.0 And my README.md looks like: ⚠️ ...
10
jekyll Blank new blog generated with Jekyll-3.2.1 on Windows
Temporary Fix I have traced that missing drive letter to site.in_theme_dir(base ...
8
blogdown Problem with blogdown::new_site using starter-hugo-academic
Should be fixed now Please try the development version of blogdown: Thanks! I have posted this issue...
7
eleventy getting data from a .json file in node_modules
Thanks @robb0wen Your example made to try and swap styles.colors.properties to styles.colour.propert...
5
jekyll jekyll 3.8.3 | Error: uninitialized constant FFI::Platform::CPU
Hmm. this is indeed frustrating Looks like you'll have to resort to setting up local bundles for eve...
4
blogdown Hugo generated .Summary lacks manual cut-off in .Rmd
It looks like Blogdown knits to html although the partials are properly processed features like summ...
3
eleventy Is it possible to paginate collection data?
To answer your second question @paulrobertlloyd the permalink front matter key can use template synt...
3
assemble yfm in partials doesn't work
Since you're using the built-in Handlebars syntax for the partial: {{> foo }} assemble does not merg...
3
jekyll Defaults: Path scope with subfolders
After a bit of testing it seems like it won't work if the value for path scope ends with a slash So ...
3
blogdown blogdown:::serve_site() keeps opening new browser tabs
@denizCvrl Thank you soooo much! By running blogdown::serve_site() multiple times ...
3
blogdown Getting started with Wowchemy
@apreshill If you are using the latest dev version of blogdown In the NEWS.md it says: When creating...
135
apostrophe PayloadTooLargeError: request entity too large when trying to POST to apostrophe-headless API
This seems to have worked: I am using apostrophe-headless and my payloads are slightly big since I a...
96
strapi 👉 Question: What are the main pain points you have using Strapi? (Episode 3)
Pain point Issue: No TypeScript support Context: I know it has been mentioned as something the team ...
82
drupal vm Composer install fails without proper swap
or you can create a swap file sudo fallocate -l 2G /swapfile sudo chmod 600 /swapfile sudo mkswap /s...
62
keystone classic Heroku Deployment - Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Found the issue! I removed this from my package.json When Heroku uses the default node version it wo...
61
Ghost using https in config.js causes "to many redirects"
Chris is correct Here is a working Nginx configuration: when im using this ...
61
strapi New project fails to connect to database
I had the same issue with 3.0.0-alpha.10 I ran strapi new project-name then when it prompts to enter...
59
ponzu no go files in /home/user/go/src/github.com/ponzu-cms/ponzu
try running go get -u github.com/ponzu-cms/ponzu/.. via copy / paste that exact command. ...
48
strapi Refresh JWT route
This is quite important for my app So I implement it by extending plugin (for temporary use) Here's ...
43
joomla cms Unknown column 'client_id' in 'where clause
The solution is to use phpMyadmin and run these queries Replace #_ by your db prefix ...
37
netlify cms Support for multilingual content authoring
So I can see from #2988 that we're still looking for UI/UX solutions on this Thanks @barthc for the ...
34
Ghost Editor: IME input problem
@buchijiang whenever the upstream issue (bustle/mobiledoc-kit#548) is solved - there's no explicit t...
29
drupal vm Failing to install Drupal on macOS High Sierra - NFS filesystem issues
@ajhoddinott OMG That works thank you! For explicit instructions on Mac OS High Sierra open the app ...
26
PrestaShop The left menu in BO disappeared after upgrade to 1.7.7.0
Hi @photinia73 @StraitsKapitan Do not rename the column active Status: Tech investigation still need...
26
october Reorder of records in relation
@canthis thank you very much the references you gave pointed me in the right direction and I was abl...
25
netlify cms Authentication problem if not running on localhost
I have the same issue with GitHub backend I can access the content manager just normal when running ...
25
netlify cms Add sorting ability to list of entries
Requesting some more flexibility here User needs: to more efficiently be able to locate a post when ...