Hakyll
Finally I’ve set up Hakyll! The current setup uses Hakyll to generate static site and Github pages to host it. It took me a fair amount of time to make things run smoothly. If you want to create a blog using Hakyll and Github pages, here is one way you could get things running.
Download Hakyll
If you have
cabal-install
installed, you may download it usingcabal install hakyll
, if not, you can download it using your package manager.Now that you have Hakyll, generate the necessary files on your computer by running
hakyll-init name-of-your-blog
.Create repository at Github
The name of the repository should be
your-userid.github.io
in order to use Github pages.Initialize the git repository:
git init
.Create
.gitignore
.Here is what my
.gitignore
looks like.git remote add origin https://github.com/username/username.github.io.git
Compile
site.hs
byghc --make site.hs
.git commit --allow-empty -m "dummy"
.git checkout --orphan source
.git submodule add https://github.com/username/username.github.io _site
In order to generate files, you can use
./site build
but if you have made deletions, then the changes do not propagate to _site folder. So you will have to use./site rebuild
which basically removes the _site folder and then starts a fresh build. The problem here is that rebuild will remove all contents of _site folder including the .git file, which messes up things. To combat this problem, I wrote a tiny scriptclean.sh
which you can get here. I recommend you download it, keep it in the same directory wheresite
executable is placed and use the script instead of./site rebuild
(you have to runsh clean.sh
.)If, by mistake, the
.git
file inside_site
got removed, you may create a file with the same name having contentgitdir: ../.git/modules/_site
.cd _site
,git add --all
,git commit -m 'changes'
.Push the changes (of
_site
folder) to github bygit push origin master
. Similarly, push the changes of the root folder (the source branch) to github bygit push origin source
.
Bonus: In the current setup, once you make the necessary changes, you will have to first commit in _site
, push to master, commit and push source. Basically you are repeating yourself. If you want to avoid this, you may you the shell script bot. Once you have in in the source directory, then run the command ./bot "Your commit message"
.
That’s it. Now your blog will be live at the address username.github.io
!
Listings
bot
script:
cd _site
git add .
git commit -m "$1"
git push origin master
cd ..
git add .
git commit -m "$1"
git push origin source
clean.sh
script:
cp _site/.git /tmp
./site rebuild
cp /tmp/.git _site/