how do i set up this blog site

how to set up a hexo blog site to be visited via *.github.io?

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.

install

First of all you should install node, npm and yarn. And then hexo itself (a git repository as starter).

npm install -g hexo-cli

Go 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 install

Now if you run the server you will be able to visit your site with a hello world post locally (localhost:4000).

hexo server

new post

Create 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.

to github

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 --save

Copy 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 deploy

and visit the website at https://sidizhan.github.io/!

dev branch

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 dev

Tips:

it 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.

in a nut shell

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 push

you need to generate the new post before deploy if you want to push the new post into github.

references

hexo

Create-Host-Blog-for-free-with-Hexo-Github

original blog can be found here

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值