最近,很想静下心来写点东西,于是,就想到了创建自己的博客。其实,以前也写过一段时间的博客,采用了HEXO的博客框架。但是,很遗憾,没能坚持下来。后来,在学习python的过程中,无意中浏览到一位博主的博客使用的是Pelican ——一款用Python编写的静态网站生成工具,想到自己原本就一直对Python很感兴趣,于是决定采用Pelican作为自己的博客框架。
由于家中有一台24小时开机的树莓派,可以被随时访问,所以我决定将博客部署在树莓派上。Pelican的初始安装和部署非常简单,通过执行几条简单的命令,就可以完成安装。但是,由于Pelican是用Python编写,所以部署的时候,必须先确保已经安装了Python。
安装Pelican之前,在/home/pi目录下,先新建blog目录,然后进入该目录。
mkdir /home/pi/blog
cd /home/pi/blog
为了能为Pelican创建一个独立的虚拟Python环境,需要先安装virtualenv,然后再创建和激活虚拟环境。
pipx install virtualenv
virtualenv venv
source venv/bin/activate
开始安装Pelican。
python -m pip install pelican
如果要使用Markdown语言,建议使用以下命令安装Pelican。
python -m pip install "pelican[markdown]"
Pelican安装成功后,完成初始配置。
pelican-quickstart
This script will help you create a new Pelican-based website.
Please answer the following questions so this script can generate the files
needed by Pelican.
> Where do you want to create your new web site? [.]
> What will be the title of this web site? My Blog //博客的站点名称
> Who will be the author of this web site? Kejiren //博客的作者名称
> What will be the default language of this web site? [English] zh //博客的语言,zh为中文
> Do you want to enable article pagination? (Y/n) Y
> How many articles per page do you want? [10] 5
> What is your time zone? [Europe/Paris] Asia/Shanghai
> Do you want to generate a tasks.py/Makefile to automate generation and publishing? (Y/n) Y
> Do you want to upload your website using FTP? (y/N) N
> Do you want to upload your website using SSH? (y/N) N
> Do you want to upload your website using Dropbox? (y/N) N
> Do you want to upload your website using S3? (y/N) N
> Do you want to upload your website using Rackspace Cloud Files? (y/N) N
> Do you want to upload your website using GitHub Pages? (y/N) y
完成以上配置后,Pelican可以算是初步部署完成了,如果以后要更改相关配置,可以通过文件pelicanconf.py来修改。
好了,下一步就可以直接将写好的文章正式发布到博客了。
,