使用python静态网页生成工具pelican快速在github上部署网站博客

简介

Pelican用Python编写的静态站点生成器。亮点:

  • 使用reStructuredText或Markdown格式直接用编辑器编写内容
  • 简单的CLI工具来(重新)生成站点
  • 易于与分布式版本控制系统和Web对接
  • 完全静态输出,可在任何地方托管

Pelican 4目前支持:

  • 文章(例如博客文章)和页面(例如,“关于”,“项目”,“联系方式”)
  • 评论,通过外部服务(Disqus)。如果您希望更好地控制评论,也可自托管评论是另一种选择。
  • 主题支持(使用Jinja2模板创建主题)
  • 以多种语言发表文章
  • Atom / RSS feeds
  • 代码高亮
  • 从WordPress,Dotclear或RSS导入
  • 与外部工具集成:Twitter,Google Analytics等(可选)
  • 借助内容缓存和选择性输出写入,可以快速重建

为什么叫“Pelican”这个名字?

“Pelican”是calepin的字谜,在法语中意为“笔记本”。 ;)

您可以访问以下网址获取源代码:https://github.com/getpelican/pelican。更多相关库参见https://github.com/china-testing/python-api-tesing

安装

pip install pelican markdown

创建项目

mkdir -p ~/projects/yoursite
cd ~/projects/yoursite
pelican-quickstart

创建文章

~/projects/yoursite/content/keyboard-review.md

Title: My First Review
Date: 2010-12-03 10:20
Category: Review

Following is a review of my favorite mechanical keyboard.

参考资料

生成网站

pelican content

预览

pelican --listen

访问:http://localhost:8000/

《使用python静态网页生成工具pelican快速在github上部署网站博客》 图片.png

github部署

比如https://github.com/china-testing/china-testing.github.io,这个仓库名要求为username.github.io

上传代码,就可以访问你的网站了。

#!/usr/bin/env bash
DATE=$(date +%Y%m%d)
cd /home/andrew/code/yoursite
rm -rf output/*
pelican content
cd /home/andrew/code/china-testing.github.io
git rm -rf *
cp -rf /home/andrew/code/yoursite/output/* .
git add *
git commit -m $DATE
git push

网站示例: https://china-testing.github.io/

    原文作者:python人工智能命理
    原文地址: https://www.jianshu.com/p/47d37723d35b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞