I tried to set up hexo once months ago, but didn’t touch it until recently. I screwed it so now I have to set it up again. In order to remember all the steps, I decide to record the process down here.
First of all you should install node, npm and yarn. And then hexo itself (a git repository as starter).
npm install -g hexo-cliGo to a directory/workspace that you want to put your site, for instance vonwunderland. Use npm to install all the required packages in package.json.
hexo init vonwunderland cd vonwunderland npm installNow if you run the server you will be able to visit your site with a hello world post locally (localhost:4000).
hexo serverCreate a new post by:
hexo new "how do i set up this blog site"then edit it with markdown format, in any text editor (me, visual studio code with markdown preview plug-in). The server will auto track the changes.
Now you want to deploy this onto github so that everyone can visit your blog site. So go to github and create a repo named yourname.github.io (my is sidizhan.github.io). Ignore the node. Then locally, install the deployer.
npm install hexo-deployer-git --saveCopy the url for repo and paste it in _config.yml, under deploy:, final edition is like:
deploy: type: git repo: git@github.com:SidiZhan/sidizhan.github.io.git branch: master message: "{{ now('YYYY-MM-DD HH:mm:ss') }}"Then, you can deploy:
hexo deployand visit the website at https://sidizhan.github.io/!
If you want to write the blog everywhere, you can push your local codes to the same repo (master has been taken as website io path, so let us choose dev).
First init the directory as a repo locally. Create dev branch to take place of master (rename?).
cd .. git init vonwunderland cd vonwunderland git checkout -b dev git add . git commit -m "set up dev"then add the remote repo here, push it.
git remote add origin git@github.com:SidiZhan/sidizhan.github.io.git git push --set-upstream origin devit may take minutes to update the setting in github.io, so if you can only visit home page by specifying the index.html (https://sidizhan.github.io/index.html), or the new posts won’t show up, just be patient and wait.
Don’t forget the process to publish a new post:
cd vonwunderland hexo new "new post" hexo generate hexo deploy git add . git commit -m "add a new post" git pushyou need to generate the new post before deploy if you want to push the new post into github.
hexo
Create-Host-Blog-for-free-with-Hexo-Github
original blog can be found here
