Ric*_*ite 6 python pelican static-generator
我已经为 Pelican 创建了自己的主题,并且已经使用它来构建我的网站有一段时间了。我决定再次开始写博客,所以我现在才向网站添加博客功能。
我已经创建了自己的blog.html模板来以我想要的方式呈现内容。我首先从Pelican 附带的“简单”主题中复制并粘贴代码以开始使用,但即使它没有改变,我在'articles_page' is undefined尝试构建时也遇到错误。
从哪里article_page设置的变量?我尝试添加到我的pelicanconf.py文件中,但没有帮助。
{% extends 'base.html' %}
{% block title %}{{ page.title }} — Ricky White{% endblock title %}
{% block content %}
<section class="wrapper">
<div class="container">
<div class="row">
<div class="col">
<ol id="post-list">
{% for article in articles_page.object_list %}
<li><article class="hentry">
<header> <h2 class="entry-title"><a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></h2> </header>
<footer class="post-info">
<time class="published" datetime="{{ article.date.isoformat() }}"> {{ article.locale_date }} </time>
<address class="vcard author">By
{% for author in article.authors %}
<a class="url fn" href="{{ SITEURL }}/{{ author.url }}">{{ author }}</a>
{% endfor %}
</address>
</footer><!-- /.post-info -->
<div class="entry-content"> {{ article.summary }} </div><!-- /.entry-content -->
</article></li>
{% endfor %}
</ol><!-- /#posts-list -->
{% if articles_page.has_other_pages() %}
{% include 'pagination.html' %}
{% endif %}
</div>
</div>
</div>
</section>
{% endblock content %}
Run Code Online (Sandbox Code Playgroud)
您必须使用以下文章引用其中一篇文章中的模板:
Template: blog
Run Code Online (Sandbox Code Playgroud)
如果您删除该引用并将以下行添加到pelicanconf.py中,Pelican 将直接从您的模板文件生成 blog.html:
DIRECT_TEMPLATES = ['index', 'blog']
PAGINATED_DIRECT_TEMPLATES = ['blog']
Run Code Online (Sandbox Code Playgroud)
(运行 pelican 之前不要忘记清空输出文件夹。在 Pelican 3.7.1 上测试)
| 归档时间: |
|
| 查看次数: |
597 次 |
| 最近记录: |