# Getting section/subsection titles for multilingual site

**URL:** <https://discourse.gohugo.io/t/getting-section-subsection-titles-for-multilingual-site/41444>\
**Category:** support\
**Created:** [November 13, 2022, 6:28pm UTC](https://discourse.gohugo.io/t/getting-section-subsection-titles-for-multilingual-site/41444 "2022-11-13T18:28:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon34553931](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@anon34553931](https://discourse.gohugo.io/u/anon34553931)\
**Post date:** [November 13, 2022, 6:28pm UTC](https://discourse.gohugo.io/t/getting-section-subsection-titles-for-multilingual-site/41444/1 "2022-11-13T18:28:53Z")

</div>

Is there a more efficient way than the way I am doing below?

```auto
               {{ if eq .Language.Lang "en" }}
               {{- with site.GetPage "blog/foo/_index.md"}}
                <a href="{{ .Permalink }}">{{ .Title }}</a>
                {{- end }}
                {{ else }}
                {{- with site.GetPage "blog/foo/_index.fr.md"}}
                <a href="{{ .Permalink }}">{{ .Title }}</a>
                {{- end }}
                {{- end }}

```

I need to replicate this in different partials and templates for different sections, but the above code seems too verbose…

---

<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:** [November 13, 2022, 7:36pm UTC](https://discourse.gohugo.io/t/getting-section-subsection-titles-for-multilingual-site/41444/2 "2022-11-13T19:36:44Z")

</div>

Get the permalink for the current section.

```nohighlight
{{ with .CurrentSection }}
  {{ .Permalink }}
{{ end }}

```

Get the permalink for a specific section:

```nohighlight
{{ with site.GetPage "/blog/foo/foo-2" }}
  {{ .Permalink }}
{{ end }}

```

When you configure your project with one language, there is one “site.”  
When you configure your project with multiple languages, there is one “site” per language.

When you do something like `.Site.GetPage` (or `site.GetPage` to avoid context issues), it is already tied to a specific language (site).

---

<div class="post-metadata">

**Author:** ![anon34553931](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@anon34553931](https://discourse.gohugo.io/u/anon34553931)\
**Post date:** [November 13, 2022, 7:48pm UTC](https://discourse.gohugo.io/t/getting-section-subsection-titles-for-multilingual-site/41444/3 "2022-11-13T19:48:51Z")

</div>

I thought it was necessary to call `_index.md` when using `.GetPage` (wrong assumption). This makes everything way easier.

```auto
{{- with site.GetPage "/blog/foo/" }}
  <a href="{{ .Permalink }}">{{ .Title }}</a>
{{- end }}

```

---

<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:** [November 15, 2022, 7:49pm UTC](https://discourse.gohugo.io/t/getting-section-subsection-titles-for-multilingual-site/41444/4 "2022-11-15T19:49:08Z")

</div>

Closed on November 15, 2022, 7:49pm UTC

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