安装Pelican

Pelican currently runs best on Python >=3.11; earlier versions of Python are not supported.

当您安装好Pelican,可以执行 pelican --help 命令来查看一些基本用法。在 发布站点 章节中可以了解更多信息。

You can install Pelican via several different methods.

Recommended method: Pip User Install

To install Pelican via Pip:

python3 -m pip install --user "pelican[markdown]"

Or, if you do not plan to use Markdown, you can omit the [markdown] suffix:

python3 -m pip install --user pelican

Alternate method 1: Pipx

Pipx lets you execute binaries from Python packages in isolated environments. You can install Pipx by following its documentation. After Pipx is installed, you can install Pelican via:

pipx install "pelican[markdown]"

Alternate method 2: uv

Like Pipx, uv allows you to install tools in isolated environments. If you have uv installed, you can install Pelican via:

uv tool install "pelican[markdown]"

Alternate method 3: Virtual Environment

If you prefer to manually manage a virtual environment, you can create a virtual environment for Pelican via venv before installing Pelican:

python3 -m venv ~/virtualenvs/pelican
source ~/virtualenvs/pelican/bin/activate
python3 -m pip install "pelican[markdown]"

Alternatively, if you have the project source, you can replace the last command with the following to install Pelican using the setuptools method:

cd path-to-Pelican-source
python3 -m pip install .

如果安装过Git,并且您希望安装Pelican的最最新版本(而不是稳定版),请使用下面的命令:

python3 -m pip install -e "git+https://github.com/getpelican/pelican.git#egg=pelican"

To exit the virtual environment, type deactivate.

可选包

如您希望使用 Markdown 来写作,执行下面的命令来安装Markdown支持:

python3 -m pip install --user "pelican[markdown]"

Typographical enhancements can be enabled in your settings file, but first the requisite Typogrify library must be installed:

python3 -m pip install --user typogrify

If you are using Pipx, you can inject packages into the Pipx-managed virtual environment. For example, to add Typogrify:

pipx inject pelican typogrify

To use uv to install Pelican with additional extra packages, use the following example command, which like above will also install Typogrify:

uv tool install --with typogrify "pelican[markdown]"

依赖

当Pelican安装完成后,下面的所有Python依赖应该都会自动安装,无需另外做任何操作:

更新升级

若是通过 Pip 安装了稳定版本的Pelican,可以通过在安装命令中添加 --upgrade 来升级到最新版:

python3 -m pip install --upgrade pelican

If you installed Pelican via setuptools or the bleeding-edge method, perform the same step to install the most recent version.

If you installed with Pipx, upgrade via:

pipx upgrade pelican

If you installed with uv, upgrade via:

uv tool upgrade pelican

启动网站

Pelican安装完成后,通过 pelican-quickstart 命令创建项目的整体框架,在运行这个命令时,您需要输入一些与站点相关的信息:

pelican-quickstart

如果是在虚拟环境中执行 pelican-quickstart ,系统会自动在 $VIRTUAL_ENV/.project 目录中查找这个命令。若这个这个命令存在并且路径是正确的,一个新的Pelican项目就会在目标位置创建。否则,会默认在当前的工作目录下创建这个项目。若要在初始化时指定项目路径,请使用 pelican-quickstart --path /your/desired/directory

当您回答完所有问题后,项目就会成功创建。项目中会包含下述的一些层级结构(除了用括号括起来的 pages)。如果有一些内容不需要按时间排序,您可以将它们放在(pages)所在的位置:

yourproject/
├── content
│   └── (pages)
├── output
├── tasks.py
├── Makefile
├── pelicanconf.py       # Main settings file
└── publishconf.py       # Settings to use when ready to publish

接下来就可以开始往 content 目录中添加自己创作的内容了。