Python 尝试在pelican中创建新帖子时出错

Python 尝试在pelican中创建新帖子时出错,python,pelican,Python,Pelican,嗨,我昨天写了一篇标题为“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/20

嗨,我昨天写了一篇标题为“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

看起来,两篇文章都有相同的slug(文章URL的本地部分)。它可以通过帖子中的“slug”元数据字段显式设置,也可以根据日期、标题等生成)。在您的情况下,两篇文章都有相同的URL“/oi.html”,pelican拒绝用第二篇文章的内容覆盖第一个生成的文件。

似乎两篇文章都有相同的slug(文章URL的本地部分)。它可以通过帖子中的“slug”元数据字段显式设置,也可以根据日期、标题等生成)。在您的情况下,两篇文章都有相同的URL“/oi.html”,pelican拒绝用第二篇文章的内容覆盖第一个生成的文件。

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

content/
├── post1.md
└── post2.md
标题相同但作者/内容不同

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."
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.
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."
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.
post2.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."
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.
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."
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.
因为鹈鹕使用帖子标题“slugified”这些帖子,它会导致名称冲突,正如您所看到的

解决方案是将
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

"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."
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.
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."
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.
post2.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."
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.
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."
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.
这将把杰基尔博士的第一篇文章输出到
oi Dr Jekyll.html
,海德先生的第二篇文章输出到
oi Mr Hyde.html

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

另请注意:


如果您想对非博客或“静态”页面执行相同的操作,例如使用标记编写的“关于我”页面,您可以使用
另存为:my_page.html
元数据强制将标记呈现到
my_page.html
,无论页面标题是什么

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

content/
├── post1.md
└── post2.md
标题相同但作者/内容不同

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."
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.
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."
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.
post2.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."
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.
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."
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.
因为鹈鹕使用帖子标题“slugified”这些帖子,它会导致名称冲突,正如您所看到的

解决方案是将
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

"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."
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.
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."
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.
post2.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."
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.
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."
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.
这将把杰基尔博士的第一篇文章输出到
oi Dr Jekyll.html
,海德先生的第二篇文章输出到
oi Mr Hyde.html

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

另请注意:


如果您想对非博客或“静态”页面执行相同的操作,例如使用标记编写的“关于我”页面,您可以使用
另存为:my_page.html
元数据强制将标记呈现到
my_page.html
,无论页面标题是什么

但我没有在第二个帖子中添加任何slug,然后就这么做错误消息说“CRITICAL:…/output/oi.html将被覆盖”意味着两篇文章要写入同一个输出文件。因此,通过在文章的标题中定义slug来明确定义输出位置。如果这样做有效,您可以找到“更好”的方法从您的帖子元数据生成slug,如果您愿意的话。一开始要明确。但我没有在第二篇博文中添加任何slug,然后就这样做。;)错误消息说“CRITICAL:…/output/oi.html将被覆盖”意味着两篇文章要写入同一个输出文件。因此,通过在文章的标题中定义slug来明确定义输出位置。如果这样做有效,您可以找到“更好”的方法从您的帖子元数据生成slug,如果您愿意的话。首先要明确。感谢“另存为”提示,这非常有用。在您回答之前,我确实得到了关于在元数据中显式指定slug的答案,这很有帮助。现在,我正在努力使后分段周明智,就像一个月有4周,但他们似乎也没有插件。不管怎样,谢谢。好吧,如果你想提出一个新问题,我会试一试。我在Jinja中做了一些数据处理,您可以在模板级别上完成。感谢“另存为”提示,这非常有用。在您回答之前,我确实得到了关于在元数据中显式指定slug的答案,这很有帮助。现在,我正在努力使后分段周明智,就像一个月有4周,但他们似乎也没有插件。不管怎样,谢谢。好吧,如果你想提出一个新问题,我会试一试。我在Jinja中做了一些日期处理,您可以在模板级别上完成。