利用sphinx+pandoc+github+readthedocs构建我的博客html
Sphinx + GitHub + ReadtheDocs 做为一个文档写做工具,利用pandoc文本转换, 用Sphinx生成文档,GitHub托管文档,再导入到 ReadtheDocs。咱们可使用这个工具写文档、记笔记等。python
此处利用的centos7.4 系统默认python版本2.7linux
[root@xuel-server ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@xuel-server ~]# python --version
Python 2.7.5
须要安装git
复制代码
pip install sphinx sphinx-autobuild sphinx_rtd_theme
复制代码
mkdir /mywike && cd /mywiki
sphinx-quickstart # 执行初始化,如下为本身输入,其余可按照默认直接回车
> Separate source and build directories (y/n) [n]: y # 建立source目录
> Project name: KaliArch SHELL BLOG # 项目名称
> Author name(s): KaliArch # 做者名称
> Project release []: 1.0
复制代码
[root@xuel-server mywike]# tree
.
├── build #文件夹,当你执行make html的时候,生成的html静态文件都存放在这里
├── make.bat
├── Makefile #编译文件用 make 命令时,可使用这些指令来构建文档输出
└── source #文件夹,文档源文件所有应所有放在source根目录下
├── conf.py #Sphinx 的配置文件
├── index.rst
├── _static
└── _templates
复制代码
开启sys和os模块
* 配置主题
html_theme = 'alabaster'
* 支持LaTeX
* 支持中文检索
extensions = ['chinese_search']
source_suffix = ['.rst', '.md']
复制代码
因为修改模板较麻烦能够直接git clone个人模板进行简单修改便可git
博客git地址github
yum install python-devel
pip install -r requirements.txt -i https://pypi.douban.com/simple/
复制代码
若是报错可能因为下载超时,从新执行便可。web
pandoc下载地址shell
cd /usr/local
wget -c https://github.com/jgm/pandoc/releases/download/2.2.3.2/pandoc-2.2.3.2-linux.tar.gz
ln -sv pandoc-2.2.3.2 pandoc
echo "export PATH=\$PATH:/usr/local/pandoc/bin" >/etc/profile.d/pandoc.sh
source /etc/profile.d/pandoc.sh
复制代码
利用pandoc将以前的markdown格式的博客源文件转换成rst格式centos
pandoc -s -t rst --toc markdown.md -o index.rst
复制代码
[root@xuel-server source]# pandoc -s -t rst --toc myshell-note.md -o myshell-note.rst
[root@xuel-server source]# ls
conf.py index.rst myshell-note.md myshell-note.rst _static _templates
复制代码
编辑index.rst,进行引用文件bash
.. toctree::
:maxdepth: 2
:caption: Contents:
myshell-note
复制代码
cd /mywiki
make html # 生成网页文件
[root@xuel-server build]# ls
doctrees html
复制代码
若是不会github能够参考git笔记markdown
若是没有readthedocs帐号能够经过github帐号登录
导入代码库
项目编译
能够经过链接地址查看博客
连接地址: