# Section URL doesn't change on content page but works on list page

**URL:** <https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623>\
**Category:** support\
**Created:** [January 17, 2022, 6:54pm UTC](https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623 "2022-01-17T18:54:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dntzbgh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dntzbgh/32/15830_2.png) [@dntzbgh](https://discourse.gohugo.io/u/dntzbgh)\
**Post date:** [January 17, 2022, 6:54pm UTC](https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623/1 "2022-01-17T18:54:07Z")

</div>

Hello, I’m trying to make a section and its pages to have different URLs based on the language that I’m currently on.

For example I wish to have a `/portfolio-es/some_post.md` for the Spanish version and `/portfolio-en/some_post.md` for the English version.  
I found out that I can use the `url` keyword in the front matter to override the URL and the `layout` keyword to point to use a single layout (so I don’t have to repeat the portfolio-lang for each language) in the list page (by adding in the front matter on `/portfolio/_index.html`). So now when I try to reach the Spanish version of the portfolio I get the url `baseURL/es/portfolio-es` which is what I want.

Seems to work but when I try to reach the post from the list it points me to an `/portfolio/some_post`, it skips the `url` keyword that I added in the front matter.

Any idea how to fix this, or is there a way to do it even better?  
Below is my project structure:

```auto
tree -I 'modules|static'
.
├── README.md
├── config.yaml
├── content
│ ├── en
│ │ ├── contact.html
│ │ └── portfolio
│ │ ├── _index.html
│ │ └── ceva.md
│ ├── es
│ │ ├── contact.html
│ │ └── portfolio
│ │ ├── _index.html
│ │ └── ceva.md
│ └── ro
│ ├── contact.html
│ └── portfolio
│ ├── _index.html
│ └── ceva.md
├── i18n
│ ├── en.yaml
│ ├── es.yaml
│ └── ro.yaml
├── resources
│ └── _gen
│ ├── assets
│ └── images
└── themes
    └── hugo-personal-theme
        ├── LICENSE
        ├── README.md
        ├── archetypes
        │ └── default.md
        ├── assets
        │ ├── css
        │ │ ├── styles.css
        │ │ └── styles.css.map
        │ └── js
        │ └── dark-mode.js
        ├── layouts
        │ ├── 404.html
        │ ├── _default
        │ │ ├── baseof.html
        │ │ ├── contact.html
        │ │ ├── list.html
        │ │ └── single.html
        │ ├── index.html
        │ ├── partials
        │ │ ├── blog-post-list-item.html
        │ │ ├── components
        │ │ │ ├── blog
        │ │ │ │ └── blog_item.html
        │ │ │ ├── projects
        │ │ │ │ └── project_item.html
        │ │ │ └── resume
        │ │ │ └── resume.html
        │ │ ├── dark-mode-switch.html
        │ │ ├── footer.html
        │ │ ├── head.html
        │ │ ├── header.html
        │ │ ├── pages
        │ │ │ ├── blog
        │ │ │ │ ├── _list.html
        │ │ │ │ └── _single.html
        │ │ │ ├── contact
        │ │ │ │ └── _single.html
        │ │ │ ├── portfolio
        │ │ │ │ ├── _list.html
        │ │ │ │ └── _single.html
        │ │ │ └── resume
        │ │ │ └── _single.html
        │ │ ├── translations.html
        │ │ └── util-fab.html
        │ └── portfolio
        │ ├── list.html
        │ └── single.html
        └── theme.toml

31 directories, 45 files

```

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [January 17, 2022, 8:47pm UTC](https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623/2 "2022-01-17T20:47:36Z")

</div>

> [@dntzbgh](#):
>
> Seems to work but when I try to reach the post from the list it points me to an `/portfolio/some_post` , it skips the `url` keyword that I added in the front matter.

If you have a relative link that begins with a forward slash then its URL will point to the host root despite the multilingual config and a content file’s `url` parameter.

For example:  
`/portfolio/some_post` ===\> `https://example.com/portfolio/some_post/`  
`portfolio/some_post` ===\> `https://example.com/<lang code>/portfolio/some_post/`

If the above does not solve your issue ,then please share the link to your repo for people to have a further look.

---

<div class="post-metadata">

**Author:** ![dntzbgh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dntzbgh/32/15830_2.png) [@dntzbgh](https://discourse.gohugo.io/u/dntzbgh)\
**Post date:** [January 18, 2022, 6:36pm UTC](https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623/3 "2022-01-18T18:36:34Z")

</div>

The thing is that I’m not using any custom URL, I just use the range function to loop over the pages of the current section:

```auto
{{ define "main" }}
portfolio-list
<br>
{{ range .Pages }}
<a href="{{.Permalink}}">to post :{{.Permalink}}</a>
{{ end }}
{{ end }}

```

and as a result I get :

```auto
portfolio-list
to post :http://localhost:61876/en/portfolio/ceva-en/

```

Since I added the url keyword to `_index.html` front matter I was expecting to get :

```auto
portfolio-list
to post :http://localhost:61876/en/portfolio-en/ceva-en/

```

but it seems to only apply the url to the list page and not the single content.

Any way to fix this?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [January 18, 2022, 6:54pm UTC](https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623/4 "2022-01-18T18:54:49Z")

</div>

> [@alexandros](#):
>
> please share the link to your repo for people to have a further look

Please.

---

<div class="post-metadata">

**Author:** ![dntzbgh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dntzbgh/32/15830_2.png) [@dntzbgh](https://discourse.gohugo.io/u/dntzbgh)\
**Post date:** [January 18, 2022, 7:27pm UTC](https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623/5 "2022-01-18T19:27:47Z")

</div>

I have created a test repo :  
[test](https://github.com/dntzbgh/hugo-test)

---

<div class="post-metadata">

**Author:** ![dntzbgh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dntzbgh/32/15830_2.png) [@dntzbgh](https://discourse.gohugo.io/u/dntzbgh)\
**Post date:** [January 22, 2022, 12:45pm UTC](https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623/6 "2022-01-22T12:45:04Z")

</div>

I have found a solution using the `permalink` keyword in the config file from a hugo issue I have discovered [here](https://github.com/gohugoio/hugo/issues/3354#issuecomment-353562669)

There is also another workaround in the comments from that same issue ([https://github.com/gohugoio/hugo/issues/3354#issuecomment-475975122](https://github.com/gohugoio/hugo/issues/3354#issuecomment-475975122))  
involving the `translationKey` keyword.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [January 24, 2022, 12:45pm UTC](https://discourse.gohugo.io/t/section-url-doesnt-change-on-content-page-but-works-on-list-page/36623/7 "2022-01-24T12:45:54Z")

</div>

Closed on January 24, 2022, 12:45pm UTC

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