andyoakley / mkdocs-blog

Blogging in mkdocs
14 stars 7 forks source link

Titles are "None" #3

Open fohrloop opened 4 years ago

fohrloop commented 4 years ago

When following the example "archive.md"

This is a list of posts, first grouped by year, then month, then sorted by age.

{% set chronological = config['chronological'] %}

{% for year in chronological|sort(reverse=True) %}
  <h3>{{ year | strftime("%Y") }}</h3>
  {% for month in chronological[year] %}
    <h4>{{ month | strftime("%B")  }}</h4>
    {% for mtime in chronological[year][month]|sort(reverse=True) %}
      {% set page = chronological[year][month][mtime] %}
      <a href="/{{ page.url }}">{{ page.title }}</a>
      <br />
    {% endfor %}
  {% endfor %}

{% endfor %}

the page titles are shown as None. image

I debugged it a little and printed page.meta which was an empty dictionary when printed to the jinja template, although I have set it using YAML syntax (also tried without setting the metadata title since I guess it should be set from the filename). I checked using a breakpoint() inside the mkdocs source code that the page.meta (and also page.title) is read correctly (inside the Page class code), so something happens between that point of code and passing the page to the jinja template.

Workaround

At time being, seems that replacing {{ page.title }} with {{ page.file.url[:-5].split('/')[-1] }} or {{ page.file.url[:-5] }} gives a desired output.

Versions

kittinan commented 3 years ago

@np-8 I got the same problem title is None