This is the accompanying repository of iahsanujunda.github.io, a personal blog powered by hexo. Hexo is a light-weight blogging engine that only depends on parsing text files.
- Markdown parsing 🌐
- Tags and Categories #️⃣
- Customizable themes ⚙️
- Blazing fast loading ⚡
First, clone this repository to the local machine. Once the repo is cloned, install all dependencies.
git clone https://github.com/iahsanujunda/iahsanujunda.github.io.git
cd iahsanujunda.github.io
npm install
From here, we can just run the site locally using hexo.
hexo server
Create new post simply by running the following command,
hexo new <title>
The new post will be generated by hexo as source/_posts/<title>.md
, and we can start writing inside this file. For convenience sake, create a new branch outside of hexo-source
and master
when creating a new post, it will let us avoid a lot of pain down the line. Once the post is finished, merge the branch back to hexo-source
to be published.
Once a new post is finished, merge the new post branch into hexo-source
branch. From here, we need to build a production site. There are two ways we can proceed with building the production site, either (1) build the hexo site locally and push this build package, or (2) leverage ci tools such as travis-ci to do the building, and put the built package to the hosting service. For github pages, second option is more recommended.
To build locally, run the following command.
hexo generate
The resulting build site will be put in public/
directory. If we have specified deployment option beforehand, we can do one line deployment after buiding production site. Several options supported by hexo includes github pages, heroku, netlify, and rsync. Read here to learn more about one-line deployment.
Running one-line deployment is as simple as,
hexo deploy
We can also deploy the content of public/
directory manually to any hosting service of our choice.
Using CI tools, we simply do git push -u origin hexo-source
to the remote repository. If we have configured CI tools to integrate with this repository, it will build the hexo site and deployed it to specified hosting service. For this site, we have specified github pages as the hosting service according to this guide from hexo. Github pages need master branch to host the site, so if we want to host the codes and site at the same repo, we need to make use of another branch as default branch, in this case we use hexo-source
. We can, of course, manually manage both master
and hexo-source
and push only appropriate content to each, but it is easy to make mistake in overwriting branches, so we offload this risk to the CI tools.
- Hexo - Node.js lightweight framework
- Github Pages - Host your project code and website in one place