试图在鹈鹕做新职位时出错

2024-10-01 02:37:25 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我昨天发了一篇题为“Oi”的帖子,现在我正试着用一个不同的标题写一篇新的帖子,但它试图搞乱旧的一个,我就是

获取此警告和错误消息:

WARNING: There are 2 variants of "oi" with lang en
WARNING: Development/web_projects/weeklyUpdate/content/2015_06_06_oi.md
WARNING: Development/web_projects/weeklyUpdate/content/2015_06_07_oi.md
CRITICAL: File Development/web_projects/weeklyUpdate/output/oi.html is to be overwritten

Tags: web消息警告标题错误contentmd帖子
2条回答

看起来,两篇文章都有相同的slug(post URL的本地部分)。可以通过“日期”字段或“标题”字段显式地生成。在你的例子中,两篇文章都有相同的URL“/oi.htmlpelican拒绝用第二篇文章的内容覆盖第一个生成的文件。在

假设你的内容目录中有两篇文章

content/
├── post1.md
└── post2.md

标题相同但作者/内容不同。在

post1.md

^{pr2}$

post2.md

Title: Oi
Author: Mr. Hyde
Date: 2015-07-15 10:20
Category: StackOverflow
Tags: pelican

"We have common friends," said Mr. Utterson.

"Common friends?" echoed Mr. Hyde, a little hoarsely. "Who are
they?"

"Jekyll, for instance," said the lawyer.

因为鹈鹕用帖子标题“重击”这些帖子,它会导致名字冲突,你会看到。在

解决方案是向每个post添加Slug: my-slug-line元数据,以强制post呈现到my-slug-line.html。在我们的例子中:

post1.md

Title: Oi
Author: Dr. Jekyll
Date: 2015-07-15 10:30
Category: StackOverflow
Tags: pelican
Slug: oi-dr-jekyll

"Well, I tell you so again," continued the lawyer. "I have been
learning something of young Hyde."

The large handsome face of Dr. Jekyll grew pale to the very lips,
and there came a blackness about his eyes. "I do not care to hear
more," said he. "This is a matter I thought we had agreed to drop."

post2.md

Title: Oi
Author: Mr. Hyde
Date: 2015-07-15 10:20
Category: StackOverflow
Tags: pelican
Slug: oi-mr-hyde

"We have common friends," said Mr. Utterson.

"Common friends?" echoed Mr. Hyde, a little hoarsely. "Who are
they?"

"Jekyll, for instance," said the lawyer.

这将把Jekyll博士的第一篇文章输出到oi-dr-jekyll.html,将海德先生的第二篇帖子输出到oi-mr-hyde.html。在

Slug:元数据是可选的,因此除非遇到命名冲突,否则您不需要来执行此操作。但它有时会派上用场。在

另请注意:

如果您想对非blog或“静态”页面执行相同的操作,比如用Markdown编写的“About Me”页面,那么可以使用save_as: my_page.html元数据强制将Markdown呈现为my_page.html,不管页面标题是什么。在

相关问题 更多 >