像黑客一样写博客–Pelican快速搭建静态博客

“像黑客一样写博客”,通过文本编辑器(Markdown编辑器)即可实现写博客,而且是静态的,很神奇吧,这里的方案是Pelican.

为啥叫 Pelican 这么奇怪的名字
“Pelican” is an anagram for calepin, which means “notebook” in French. 😉

Pelican 是基于Python实现的开源静态博客系统,所谓静态博客系统就是无需数据库,每一篇文章会事先渲染成HTML静态文件,访问速度非常快。所以今天给大家介绍下怎么使用Pelican。

安装 pelican
pip3 install pelican markdown –upgrade

创建项目

>mkdir blog  # 创建项目目录

>cd blog # 进入项目目录

\blog>pelican-quickstart  # 生成pelican骨架
Welcome to pelican-quickstart v3.7.1.

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.
...
Done. Your new project is available at \blog

安装过程过,会有很多需要你输入的配置项,如果不知道怎么填就直接忽略或者选择n,因为这些配置项在后面可以自己手动再添加的。

创建完成后生成的目录结构如下
.
├── Makefile # 管理博客
├── content/ #存放文章的源文件
├── develop_server.sh
├── fabfile.py
├── output/ #生成的静态文件存放目录
├── pelicanconf.py #博客配置文件
└── publishconf.py #发布文件

第一篇makedown文章
你的文章需要保存在content目录下,通常情况我们写文章采用markdown语法,所以,现在我们在content目录创建一篇文章,文章内容:

Title: My super title
Date: 2010-12-03 10:20
Modified: 2010-12-05 19:30
Category: Python
Tags: pelican, publishing
Slug: my-super-post
Authors: Alexis Metaireau, Conan Doyle
Summary: Short version for index and feeds
This is the content of my super blog post.

生成静态文件
pelican content

执行完成后,output 目录会多出一些文件,markdown文件最终也会转换成html文件放到该目录下

选择Apache 虚拟文件路径,启动你的博客网站吧: http://Youthblue.com

高级功能1:配置主题
在http://www.pelicanthemes.com/选择自己喜欢的主题
将从pelican-themes上下载主题到本地并安装
git clone https://github.com/getpelican/pelican-themes.git

在pelicanconf.py文件中,配置主题
THEME = “pelican-octopress-theme”

高级功能2:修改时区和默认的时间格式
TIMEZONE = ‘utc’
DATE_FORMATS = {
‘en’: ‘%a, %d %b %Y’,
‘jp’: ‘%Y-%m-%d(%a)’,
‘zh’: ‘%Y-%m-%d(%a)’,
}

AD:
http://kylinholding.com/

来源:–如果你觉得对你有帮助,麻烦请帮点一下广告 — 就当请我吃颗糖 🍑🍒🍓,多谢。

posted on 2019-11-29 08:56  518fans粉丝网  阅读(246)  评论(0编辑  收藏  举报