Making a Github blog from Notion pages

Posted on Sun, Jul 25, 2021 how-to web blogs

I have been on an eternal search for an easy to create and deploy static site generator. I started with Pelican and hosted my blog on GitHub. Later I moved to Hugo which was faster, well maintained and had a less tedious workflow. The problem was that I kept forgetting simple stuff - which directory am I supposed to save the images, what are the set of commands that needs to be executed to compile and push stuff. I can create a shell script for all of this - but again I am very clumsy - I end up deleting important scripts as well (huh, then what's git for? I should stop giving excuses). Had the workflow been simpler, looking up the documentation would have taken much less time. The major drawback was that I used to write my blog post in some markdown editor which I did not enjoy using. To put it simply: it was too much of an effort to write a new blog.

Notion for taking notes.

Recently I came across Notion (the personal plan is free) which helped me write and organize my notes in a very flexible way. It has good LaTeX\LaTeX support and I can paste images anywhere on the page. I can have sub-pages in a given page. I can also share my notes with anybody. After using it for a while, I decided to start maintaining all my notes on Notion. Only time will tell if this was a good decision.

Notablog

Thanks to Alexander Wang's Notablog we can easily convert notion pages to a html blog which can further be hosted on some server (say Github Pages). Follow the instructions in this readme to setup your own blog from notion pages.

Workflow for pushing to GitHub Pages

I now assume that you have gone through the instructions in the readme and learnt how to generate a blog locally with Notion + Notablog.

$mkdir blog_name.github.io
$cd blog_name.github.io
$git init
$git remote add origin https://github.com/YourAccountName/blog_name.github.io.git
$touch readme.md
$echo 'My personal Blog' > readme.md
$git add readme.md
$git commit -m "First commit"
$git push -u origin main
notable_blog_dir=../; # where is your notion blog? 
cur_dir=$(pwd); # your github blog dir
cd $notable_blog_dir;
notablog generate .; # compile blog again
cp -r public/. $cur_dir/.; # copy changes
# commit and push changes
cd $cur_dir; 
git add .;
commit_msg="${1:-'re-generated blog'}";
echo $commit_msg;
git commit -m "$commit_msg";
git push -u origin main;
$chmod +x workflow.sh
$./workflow.sh "some commit message" # commit message is optional