【问题标题】:Using Pelican Static Site Generator for something other than a blog将 Pelican 静态站点生成器用于博客以外的其他内容
【发布时间】:2017-02-13 05:16:19
【问题描述】:

我正在尝试使用 Pelican 静态站点生成器来创建一个不是博客的静态站点。

content/posts 文件夹中的每个 markdown 文件都包含以下数据。

---
name: Product Name here
price: Product Price goes here
image: Product Image goes here 
---

The description content in Markdown goes here

但是当我预览该站点时,我收到以下错误消息:Skipping filename.md: could not find information about 'title'。如果我将所有降价文件移动到 content/pages 文件夹中,我会收到相同的错误消息。

我想在主页(index.html)上显示产品信息(如上图存储在markdown文件中)

如何使帖子文件夹中的内容不被视为文章,或者换句话说,使文章的标题和日期元数据成为可选的?

【问题讨论】:

  • 你有什么理由不能给你的页面标题?为什么不使用标题来保存产品名称?如果你不希望你的页面是过时的文章,那么他们需要进入content/pages
  • 您可以在本例中使用标题作为产品名称,但我们假设它没有被称为标题,而且对于某些其他数据,拥有标题字段可能没有意义。跨度>
  • 因此,您希望将工具用于其预期目的之外的其他用途,并且您不愿意做出一些妥协。那我恐怕也帮不上忙了,只能建议你找个不同的工具。

标签: python markdown pelican static-site yaml-front-matter


【解决方案1】:

将您的 name 字段重命名为 title

---
title: Product Name here
price: Product Price goes here
image: Product Image goes here 
---

The description content in Markdown goes here

两者之间几乎没有语义差异,但 Pelican 需要有 title 提要。或者,只需将其设置为未使用的值:

---
title: none
name: Product Name here
price: Product Price goes here
image: Product Image goes here 
---

The description content in Markdown goes here

【讨论】:

    猜你喜欢
    • 2014-10-10
    • 1970-01-01
    • 2016-03-01
    • 2011-07-06
    • 1970-01-01
    • 1970-01-01
    • 2011-02-20
    • 1970-01-01
    • 2016-09-17
    相关资源
    最近更新 更多