嗨,我昨天发了一个标题为“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
Run Code Online (Sandbox Code Playgroud)
假设您的内容目录中有两个帖子,
content/
??? post1.md
??? post2.md
Run Code Online (Sandbox Code Playgroud)
具有相同的标题但不同的作者/内容。
post1.md
Title: Oi
Author: Dr. Jekyll
Date: 2015-07-15 10:30
Category: StackOverflow
Tags: pelican
"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."
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
因为 Pelican 使用帖子标题“slugizing”了这些帖子,所以会导致名称冲突,正如您所看到的。
解决方案是将Slug: my-slug-line元数据添加到每个帖子,以强制帖子呈现为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."
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
这将输出 Jekyll 博士的第一篇文章oi-dr-jekyll.html,以及 Hyde 先生的第二篇文章oi-mr-hyde.html。
该Slug:元数据是可选的,所以你不要有这样做,除非你遇到了命名冲突。但它有时会派上用场。
另请注意:
如果你想对非博客或“静态”页面做同样的事情,比如用 Markdown 编写的“关于我”页面,你可以使用save_as: my_page.html元数据强制将 Markdown 呈现为my_page.html,无论页面标题发生了什么是。