How to name list templates?

pluralizelisttitles: false

Should work.

Yes, this would remove “s” at the end, but I still need “Programska rješenja” instead of “Programsko-rjesenje”.

I believe there should be a way to put a custom title on sections. The name of the section determines the path but should not determine the title of the sections page.

I agree, but where to store it? config.toml?

To me, the option to add a content index.md file within the sections root where we can use the power of front matter to determine all the page parameters (title, description, etc) would be ideal but that’s very opinionated and i believe it goes against how hugo was designed.

It would also be interesting if in this section index file we can create a shortcode where we can add the page iteration code where we want it. Once again, this is my opinion and i’m sure will require a pretty big rewrite to allow all the advantages of a section template to work within a content file. (ex: pagination, etc.)

What do you think bjornerik?

Nodes currently have no front matter.

I don’t see the index.md idea going anywhere …

section.toml etc. could maybe be an idea.

That would work for me!

I think config would be good place for that, similar way taxonomies are defined singular=plural.
It could work same way for list pages.

How difficult do you think this will be to incorporate?

Create an entry in the data/ directory to hold an override of plural mappings. If present, have Hugo use it for the values. Wouldn’t that allow it to be included in themes? And then be something that could be overridden by putting your own copy in the top layouts/ directory? Plus, you could do plurals-en, plural-de, etc, to allow plurals for any language (sort of assumes that a language is specified in config.toml, though).

While that isn’t exactly what’s asked for here, what you suggest would be an easy workaround:t

for a title with the key my-list

/data/titles.toml having a key/value my-list => "My Custom Title'

And then in template:

{{ index .Data.titles .Title }}

Something like that. Totally untested.

This works and it is acceptable solution for now (of course, it would be great if it would work automatically in some manner)

My titles.toml:

[Programsko-Rjesenjes]
title = "Programska rješenja"
description = "Naša programska rješenja kreirana za vaše potrebe"

Here is the code in list.html

{{ .Scratch.Add "title" "" }}
{{ .Scratch.Add "description" "" }}

{{ if isset .Site.Data.titles .Title }} 
    {{ .Scratch.Set "title" (index .Site.Data.titles .Title).title }} 
    {{ .Scratch.Set "description" (index .Site.Data.titles .Title).description }} 
{{ else }} 
    {{ .Scratch.Set "title" .Title}} 
    {{ .Scratch.Set "description" .Description}} 
{{end}}

And it is used in HTML like this:

<h2 class="page-header-title" data-ix="page-title">{{ .Scratch.Get "title" }}</h2>
<h2 class="page-header-title description" data-ix="page-title-2">{{ .Scratch.Get "description" }}</h2>

Thanks for suggestion.

2 Likes

This is a decent workaround but I still do prefer bjornerik’s original idea of having a config file within the section directory where the pages properties can be determined.

Not sure if anyone else would agree whether this should be on the roadmap or not.

1 Like

I guess this is still an issue.

Since sections are quite common in websites, I think it would make sense to have an md file within the content directory.

index.md could work, but also the following could
/content/section1/ ................./section1.md ......../section2/ ................./section2.md

So you could use the matching of section name and md file to trigger inclusion of content.

I think this makes a lot of sense since it isn’t just frontmatter that would be useful for sections. Content would also be useful, which at the moment you have to put in layouts/section1.html which seems like poor separation of layout and content.

See

Should this workaround still work around in Hugo v0.16? And is it still the best workaround for generating Section List titles? I’m having a horrible time trying to make Section titles work even with @mblataric’s code.

To clarify, I’m trying to display the Section name on the following template…

/themes/[mythemename]/layouts/section/[sectionname].html

OK, this is now fixed in v0.18.1 via the use of an _index.md file in your content/section folder as discussed in the docs here and on the forum here.

This worked for me, but also should be noted that defining “title” in the header metadata doesn’t seem to work so I had to use some other variable name like “displaytitle”.

For other beginners like me, all metadata variables must be all lowercase letters only, no special characters, and then you access them in your layouts with .Params.variablename

Hope that helps!

Do you mean?

<head>
    <title>{{.Title}}</title>>
</head>

This should work on both section/list and single content pages.

1 Like

haha duh. Yes!

1 Like