Hi,
I am testing out Zola for a blog but I have some difficulties making the page title and the TOC work together. So for each article I have a title in the front matter so that it can be displayed on the home page with some short summary / description. In the page template I added the page title as h1 before the page content. However, when using the page TOC the page title is not included because it is not a title in the content.
I tried to concat the page title with the TOC like this:
{% set toc = [page.title] %}
{% set toc = toc | concat(with=page.toc) %}
But this does not work because the page title does not have a permalink like the other headings in the TOC.
The other thing I could do is to include the title in the markdown file as a level 1 title. This would solve the TOC problem, however I didn’t see a way to get the first title from the content and treat it as the page title. So I would have to duplicate the page title in the front matter and then as an actual title
Is there a way to achieve this easily, maybe I missed something?
And if it is not, maybe we can add the possibility for Zola to extract the first title of the content and consider it the page title? Or an option to add the page title to the toc?
Also, I think I found a bug when trying to do this?
The snippet above works, but when you try to do the same on one line you get an error:
{% set toc = [page.title] | concat(with=page.toc) %}
Error:
* Failed to parse "page.html"
--> 17:51
|
17 | {% set toc = [page.title] | concat(with=page.toc) %}␊
| ^---
|
= expected `%}` or `-%}`