Let's blog with Pelican
Makefile
-
make html: generates output html files from files incontentfolder using development config filemake regenerate: domake htmlwith "listening" to new changes- vs.
make publish: similar tomake htmlexcept it uses settings inpulishconf.py
-
make serve: (re)starts a http server in theoutputfolder. Default port is 8000 - Go to
localhost:<PORT>to see the output website ghp-import -b <local-gh-branch> <outputdir>: imports content in
Workflow
Key points:
- Do every work in
devbranch. - Do not touch
blog-buildormaster. blog-buildwill be indirectly modified byghp-import(ormake publish-to-github)- and
masteris the branch that Github will access to show my website. - So, manage the source (and outputs) only in
devbranch.
Local dev
- Activate the right conda env with
pelicanlibrary
conda activate my-blog
cd ~/Workspace/Blog
-
Make sure you are on
devbranch git checkout dev -
(this step is for github syncing) Add new files under
contentgit add my-article.md -
Generate the content with pelican make html # or, make regenerate
-
Start a local server make server
-
Open a browser and go to localhost:8000 Or whatever the port number is, set in Makefile (under the variable name of PORT)
Global dev
- Use
make publishinstead ofmake html - Update the
blog-buildbranch with contents inoutputfolder - Push the
blog-buildbranch's content toorigin/master
These three steps can be done in one line:
make publish-to-github
Version control the source
Important: Write new contents only on the dev branch
git add <files> # make sure not to push the output folder
git cm "<commit message>"
git push origin dev #origin/dev is the remote branch that keeps track of blog sources