I have section with list of mentions (for example).
For now Title set automatically with name of file. But my site in Russian language & I need title in Russian. Title in Russian present in menu (config.toml), but I don’t Understand how to set tag title
with name of current menu.
This is one of my sections: https://github.com/pavlik/kuda.pro/blob/master/layouts/section/mention.html
You have the Russian title
set in your content already. Use the .Title
property of the page in the range.
{{ range .Data.Pages }}
<h3>{{ .Title }}</h3>
{{ .Content }}
....
{{ end }}
I need own title in head > title
So, you want the title of the Section? That’s not currently supported. Sections are called “Nodes” inside of Hugo, and you can’t currently set front matter properties on Nodes. See Node Improvements for a discussion of the limitations and future plans.
I’m not sure how you would be able to use the existing menu definitions. You may be able to create a map in your config.toml like this:
[mentions]
"1" = "Отзыв Кондрашова Евгения Михайловича"
"2" = "Отзыв Игоря и Виктории Шубиных"
Then in your template do something like:
{{ echoParam .Site.Params.mentions .Title }}
I haven’t tried that, though. It’s just an idea.
I’m not sure if I’m following the question, but this is how I’m able to get a section title.
Eg,
In a list page (/layouts/section/posts.html
)
<h1>{{ .Title | upper }}</h1>
=> <h1>POSTS</h1>
In a single page within the same content section =
<!-- using /content/posts/my-first-post.md as an example -->
<article>
<header>
<h1>{{ .Section | upper }} - {{ .Title | upper }}</h1>
</header>
</article>
=>
<h1>POSTS - MY FIRST POST </h1>
In the <head><title>
I’m guessing you could use some if-else logic with .IsNode
, .IsPage
, and .IsHome
right, @moorereason?