Pelican的*_SAVE_AS设置为””仍在生成页面。

huangapple go评论52阅读模式
英文:

Pelican *_SAVE_AS settings set to "" are still generating pages

问题

根据Pelican 4.8.0的文档,我应该能够通过将页面的值设置为空字符串来阻止某些页面的创建。

我是我的博客唯一的作者,并设置了一个简单的关于我页面,比作者页面提供了更多的细节。在文档中有这样的说明:

> 如果你不想创建一个或多个默认页面(例如,你是站点上唯一的作者,因此不需要作者页面),将相应的 *_SAVE_AS 设置为 '' 以阻止生成相关页面。

依照这个指导,我在我的配置文件中设置了以下数值:

AUTHORS_SAVE_AS = ""
AUTHOR_SAVE_AS = ""

不幸的是,整个 authors.html 和单独的作者 author/NewGuy.html 仍然被生成。

我正在使用Pelican 4.8.0

是否有一种新的/更好的方法来防止生成这些页面?遗憾的是,在这种情况下,文档似乎并不完全准确。

英文:

According to the documentation for Pelican 4.8.0, I should be able to prevent the creation of certain pages by setting their value to an empty string.

I am the only author of my blog, and have set up a simple about me page, with more detail than the author page provides. Within the docs is this note:

> If you do not want one or more of the default pages to be created (e.g., you are the only author on your site and thus do not need an Authors page), set the corresponding *_SAVE_AS setting to '' to prevent the relevant page from being generated.

Using this as my guidance, I've set the following values in my config file:

AUTHORS_SAVE_AS = ""
AUTHOR_SAVE_AS = ""

Unfortunately, both the overall authors.hml and individual author author/NewGuy.html are still being generated.

I am using Pelican 4.8.0

Is there a new/better way to prevent these pages from being generated? Sadly, the documentation doesn't appear to be 100% accurate in this case

答案1

得分: 1

由于我观察到的行为恰好与记录的行为相符(即,我无法复制您描述的行为),最有可能的解释是这些伪文件是前一代运行(在您将这两个设置设为空字符串之前)留下的。正如设置文档中所指出的那样,默认行为是保留 output 文件夹并在其上生成文件。如果这不是您期望的流程,您可以像文档中所述设置 DELETE_OUTPUT_DIRECTORY = True

无论如何,您可以在一次性的基础上手动实现相同的效果:我建议完全删除您的输出文件夹并重新生成站点,以确保您获得完全新的构建。

以下步骤是我用来确认记录的行为似乎是准确的:

#(创建新的虚拟环境)
python -m pip install pelican[markdown]
pelican-quickstart
#(回答问题)
cd my-new-site
pelican
ls output | grep authors  # 在控制台中打印authors.html
vim pelicanconf.py
#(将上述两个设置设为空字符串)
pelican
ls output | grep authors  # 在控制台中*不*打印authors.html
英文:

Since the documented behavior is precisely what I observe (i.e., I can't replicate the behavior you describe), the most likely explanation is that those spurious files are left over from a previous generation run (before you set those two settings to empty strings). As noted in the Settings Documentation, the default behavior is to leave the output folder in place and generate files on top of it. If that is not your desired flow, you can set DELETE_OUTPUT_DIRECTORY = True as noted in the docs.

Either way, you can achieve the same effect manually on a one-time basis: I suggest removing your output folder entirely and re-generating your site, in order to ensure you are getting a completely fresh build.

The following steps are what I used to confirm that the documented behavior appears to be accurate:

# (Make new virtual environment)
python -m pip install pelican[markdown]
pelican-quickstart
# (Answer questions)
cd my-new-site
pelican
ls output | grep authors  # authors.html printed in console
vim pelicanconf.py
# (Set above two settings to empty strings)
pelican
ls output | grep authors  # authors.html is *not* printed in console

huangapple
  • 本文由 发表于 2023年2月8日 13:04:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75381553.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定