I want to create a long static website with Pelican and I'm not sure how to do it. I've got 3 sections with corresponding content in md files:
- landing.md
- about.md
- contact.md
Each of this section has separate template defined:
- landing.html
- about.html
- contact.html
I define it in the markdown file with Template: <file>. I would like to simply generate one site that will have all these 3 sections/pages one under another. I tried something like this:
index.html
{% extends "base.html" %}
{% block content %}
<p>index.html</p>
{% for article in articles_page.object_list %}
{% block article %}{% endblock %}
{% endfor %}
<p>end of index.html</p>
{% endblock %}
and in templates:
{% extends "index.html" %}
{% block head %}
{{ super() }}
{% endblock %}
{% block article %}
<h1 style="color: red">{{article.title}}</h1>
{{article.content}}
{% endblock %}
but I am not allowed to add block article in the template, it results in articles_page undefined error.
Is it at all possible to generate the file like that in Pelican? What would be the best practice to do it? I would like to have a one long static website and be able to maintain the content conveniently, hence I thought about SSG.
If you have the content for the pages in a content/pages directory then you can loop through in
index.htmlthem usingThe
pagesvariable is available on all templates.You may want to have the pages in a certain order and so you can either add an attribute, such as "order" to the meta data and then sort by that with
Or another way is to have multiple loops and filter the loop using selectattr, such as
You could add one of these loops to a partial template for each section and include it into your
index.htmlwith