This is step-by-step guide walks you through creating a fast, static blog use Hexo, deploying it seamlessly to GitHub Pages for free hosting, and styling it with Melody theme. One-time setup(config github, dependencies), maintain & develop by using Markdown, modify js/css without worry about database.
Prerequisites
Install Node.js and npm on your system.
Set up a GitHub account and create a new repository (e.g., username.github.io for GitHub Pages).Don’t need to git clone this new repo.
Solution1: Use Main Branch
Install Hexo
1
npm install -g hexo-cli
1
hexo -v
Initalize Your Blog and install Melody(for Hexo v5+)
Edit the _config.yml file in the root directory of your project:
Update site details:
1 2 3 4 5 6 7 8
url: https://username.github.io
theme: melody
deploy: type: git repo: git@github.com:username/username.github.io.git branch: main
For Hexo v5+, copy the default Melody configuration: Create _config.melody.yml in your root directory. Copy contents from node_modules/hexo-theme-melody/_config.yml into _config.melody.yml.
Install Hexo Git deployer
1
$ npm install hexo-deployer-git --save
Verify in Local
1
$ hexo clean && hexo g && hexo s
Push to production
1
$ hexo clean && hexo g && hexo d
Deploy your blog
Go to your blog repo in github UI -> Settings -> Pages -> Source build choose Deploy from a branch -> Branch choose main /root save
Go to your terminal, under blog repo:
1
$ hexo clean && hexo g && hexo d
Check github action(on the right bar of repo) if ready