Questions about list layout

I have list.html file inside layouts/_default.

My content folder looks like that:

I want to get the name of the folder inside of this list.html file and change the page’s title. Could you help me with that? I want the title to be different for every list. For example, if it is Canada, I want it to be: “Student Stories | Canada”, if it is the Netherlands, I want the title to be “Student Stories | Netherlands”

there are different ways to do it

1st use different directories ./canada ./netherlands etc… use {{.section}} in the title
2nd set a parameter in frontmatter country: “Netherlands” and use {{}}
3rd a lot more :wink:

1 Like

Sorry, but I don’t really understand either ways :frowning:

  1. I tried to render {{ .section }} in list.html, but I got error executing "main" at <.section>: can't evaluate field section in type *hugolib.pageState
  2. This I didn’t understand at all :frowning:

Should be .Section or .CurrentSection

As @ju52 suggested, you can use something like:

{{ if eq .Section "canada" }}
{{ end }}

In your case you can do something much more simple:

Just put a file into your folder /content/canada/.

In this file add the following front matter:

title: Student Stories | Canada
1 Like