Closed jfcherng closed 6 years ago
articles_page
is available for templates in PAGINATED_DIRECT_TEMPLATES
. So, the way you want to use page
here is not possible. Putting it in paginated as well as :template:
will cause it to be rendered twice: once with page
and once with articles_page
but neither will have both at the same time.
A way to achieve it would be putting the content in a regular (or maybe hidden) page with a custom flag metadata and looping it over there:
page
:date: 2013-02-20
:title: My Index
:front: true
:status: hidden
Page Content
============
Hello World!
template
{% extends "base.html" %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="main-section page-content">
{% for page in hidden_pages %}
{% if page.front == "true" %}
{{ page.content }}
{% endif %}
{% endfor %}
</div>
</div>
<div class="col-md-12">
{% include 'component/latest_articles.html' %}
</div>
</div>
{% endblock content %}
@avaris That's smart and it works like a charm! Thank you!
Environment
My Goal
I would like to have the following two things in my rendered
index.html
.My Thought
I make a custom template (
custom/index_with_content_top.html
) and use:template:
in the .rst file (pages/index.rst
) to render it with the custom template.Problems
Pelican reports
CRITICAL: UndefinedError: 'articles_page' is undefined
. After some survey, it looks like that in mypelicanconf.py
, I have to add'custom/index_with_content_top'
intoDIRECT_TEMPLATES
andPAGINATED_DIRECT_TEMPLATES
to get access toarticles_page
. But after adding, thepage
variable is no longer available in'custom/index_with_content_top'
. Pelican reportsCRITICAL: UndefinedError: 'page' is undefined
.If my thought is impractical, is there another way to achieve my goal?
Source Codes
pages/index.rst
:custom/index_with_content_top.html
: