Let's blog with Pelican
Makefile
-
make html
: generates output html files from files incontent
folder using development config filemake regenerate
: domake html
with "listening" to new changes- vs.
make publish
: similar tomake html
except it uses settings inpulishconf.py
-
make serve
: (re)starts a http server in theoutput
folder. 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
dev
branch. - Do not touch
blog-build
ormaster
. blog-build
will be indirectly modified byghp-import
(ormake publish-to-github
)- and
master
is the branch that Github will access to show my website. - So, manage the source (and outputs) only in
dev
branch.
Local dev
- Activate the right conda env with
pelican
library
conda activate my-blog
cd ~/Workspace/Blog
-
Make sure you are on
dev
branch git checkout dev -
(this step is for github syncing) Add new files under
content
git 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 publish
instead ofmake html
- Update the
blog-build
branch with contents inoutput
folder - Push the
blog-build
branch'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