pelicanでmarkdownをブログにする

wordpressの管理が面倒で、
もっとシンプルにgithubにcommit/pushするだけでできないものかと試してみた。
まだ途中だがgithubにUPするところまで書きたい。

[新しいバージョンのPelicanを使ったときの記事を書きました。](https://pakhuncho.github.io/pakhuncho-blog/making-plican-blog.html)

# 参考

* [公式サイト](https://docs.getpelican.com/)
* [公式サイトのQuickstart](https://docs.getpelican.com/en/4.0.1/quickstart.html)

# 環境

* Windows10
* Python 3.8.2

# インストール

```console
> pip install pelican markdown
Collecting pelican
  Downloading pelican-4.5.0-py2.py3-none-any.whl (673 kB)
     |████████████████████████████████| 673 kB 2.2 MB/s
Collecting markdown
  Downloading Markdown-3.2.2-py3-none-any.whl (88 kB)
     |████████████████████████████████| 88 kB 4.0 MB/s
Collecting feedgenerator>=1.9
  Downloading feedgenerator-1.9.1-py3-none-any.whl (22 kB)
Collecting jinja2>=2.11
  Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 6.8 MB/s
Collecting unidecode
  Downloading Unidecode-1.1.1-py2.py3-none-any.whl (238 kB)
     |████████████████████████████████| 238 kB 6.4 MB/s
Collecting pygments
  Downloading Pygments-2.7.0-py3-none-any.whl (950 kB)
     |████████████████████████████████| 950 kB 6.8 MB/s
Collecting docutils>=0.15
  Downloading docutils-0.16-py2.py3-none-any.whl (548 kB)
     |████████████████████████████████| 548 kB 6.4 MB/s
Collecting python-dateutil
  Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
     |████████████████████████████████| 227 kB 6.8 MB/s
Collecting blinker
  Downloading blinker-1.4.tar.gz (111 kB)
     |████████████████████████████████| 111 kB ...
Requirement already satisfied: pytz>=0a in c:\users\username\appdata\local\programs\python\python38\lib\site-packages (from pelican) (2020.1)
Collecting six
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting MarkupSafe>=0.23
  Downloading MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl (16 kB)
Building wheels for collected packages: blinker
  Building wheel for blinker (setup.py) ... done
  Created wheel for blinker: filename=blinker-1.4-py3-none-any.whl size=13455 sha256=57daa4945a8c37e456b038a3022c48e58d2d7f7e1d02cb7efc612448ad4b89ef
  Stored in directory: c:\users\username\appdata\local\pip\cache\wheels\b7\a5\68\fe632054a5eadd531c7a49d740c50eb6adfbeca822b4eab8d4
Successfully built blinker
Installing collected packages: six, feedgenerator, MarkupSafe, jinja2, unidecode, pygments, docutils, python-dateutil, blinker, pelican, markdown
Successfully installed MarkupSafe-1.1.1 blinker-1.4 docutils-0.16 feedgenerator-1.9.1 jinja2-2.11.2 markdown-3.2.2 pelican-4.5.0 pygments-2.7.0 python-dateutil-2.8.1 six-1.15.0 unidecode-1.1.1
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
You should consider upgrading via the 'c:\users\username\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command.
```

jinja2など、必要なライブラリも色々インストールされる。

# プロジェクト作成

## ディレクトリ作成

```
mkdir -p mysite
cd mysite
```

## プロジェクト作成

コマンド実行すると色々質問される。

```
> pelican-quickstart
Welcome to pelican-quickstart v4.5.0.

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? MyBlog
> Who will be the author of this web site? HyunwookPark
> What will be the default language of this web site? [Japanese] ja
> Do you want to specify a URL prefix? e.g., https://example.com   (Y/n) n
> Do you want to enable article pagination? (Y/n) n
> What is your time zone? [Europe/Paris] Asia/Tokyo
> 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
> Is this your personal page (username.github.io)? (y/N) y
Done. Your new project is available at D:\work\mysite
```

```:作られたディレクトリ
mysite
├─content
└─output
```

**作ったmarkdownはこんな感じ↓**

---
Title: My First Review
Date: 2010-12-03 10:20
Category: Review
Tags: テスト, 投稿
Summary: どんな感じに出るのか

\# テストタイトル

この内容がどのように出力されるのか。

\`\`\`python
print('HelloWorld')
\`\`\`

\### テーブル

\|項目|内容|
\|---|---|
\|python|プログラム言語|

\### リスト

\* リスト
\* リスト

\1. リスト
\1. リスト

---


```
> pelican content
WARNING: Watched path does not exist: mysite\content\images
Done: Processed 1 article, 0 drafts, 0 pages, 0 hidden pages and 0 draft pages in 0.31 seconds.
```

```
mysite
├─content
├─output
│  ├─author
│  ├─category
│  ├─tag
│  └─theme
│      ├─css
│      ├─fonts
│      └─images
│          └─icons
└─__pycache__
```


# 実行

```
> pelican --listen

Serving site at: 127.0.0.1:8000 - Tap CTRL-C to stop
```

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/224453/529f66f3-5b51-795e-1ec5-bb5b8517ef09.png)

# テーマの変更

https://github.com/getpelican/pelican-themes