利用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帳號登錄
導入代碼庫
項目編譯
能夠經過鏈接地址查看博客
連接地址: