Recently the computer was broken, so all study resources were lost, and before I didn’t like backup files, I had to learn to build a personal blog with Hexo and Github. Write this file, so last time will not waste too much time to redo the same things as today.
Important
(How to use GitHub redeploy blog):
Download the source file from the gh-pages branch from github repository.
Generate a new Post with the command:
1 | hexo n post <Here-is-post-name> |
then a .md file and a folder with the same name <Here-is-post-name> will be automatically generated.
- Add relative pdfs or images in <Here-is-post-name> folder
and edit the <Here-is-post-name>.md file.
- Insert pdf files to post:
1 | <object data="./Poster_ADL-AI_final.pdf" type="application/pdf" width="100%" height="877px"> |
- Insert images to post:
1 |  |
- Git push local gh-pagesrepository to remote repository
1 | $ git add . |
- Finally, run:
1 | $ hexo clean && hexo g -d |
- Reset the domain in your repository
Setting
on GitHub:
Warning:
If you met (Your Connection is Not Private error) or (The custom domain for your GitHub Pages site is pointed at an outdated IP address. You must update your site’s DNS records if you’d like it to be available via your custom domain. ), maybe everything are right, you just need to wait a few hours:
On Ubuntu
1. Learn Hexo Blog Framework:
- install hexo:
npm install -g hexo
- Initlize hexo:
hexo init
- Install required packages:
npm install
- Deploy Hexo:
hexo s
- Open
localhost:4000
in browser.
Hexo
2. Use NEXT Thema in Hexo:
Next Thema Website
ps: This blog is using Next-Gemini.
- Install Thema:
1 | $ cd hexo |
- Set up the theme, in _config.yml change:
1 | theme: next |
- Set up the scheme, in themes/next/_config.yml change:
1 | scheme: Gemini |
Set up menu: user can directly use Font Awesome icon in
themes/next/_config.yml
Dynamic background, modify
themes/next/_config.yml
:
1 | canvas_nest: |
- Add visitor comment, modify
themes/next/_config.yml
, first register a count in Disqus:
1 | # Multiple Comment System Support |
3. Delete a post in hexo
Delete the post under source/_post folder
Run hexo clean to delete the database (db.json) and assets folder
Run hexo generateto generate the new blog without your deleted post
Run hexo deploy to deploy your blog
4. Connect Hexo with Github
deploy hexo on GitHub pages: build a new repository with the name: <username.github.io>, create a new branch
git clone this repository and copy hexo file into this folder
modify the
_config.yml
1 | deploy: |
when there is Deploy error
:
1 | npm install hexo-deployer-git --save |
- generate and deploy
1 | hexo clean && hexo generate |
- Important: Use
store and update files, store static pages, so always run command in hexo branch
5. Achieve Automated Deployment:
- comment
repo
in _config.yml:
1 | deploy: |
In local blog directory create a folder with name
.travis.yml
, it exists in the same directory with_config.yml
.Input this command:
1 | sudo: false |
Don’t need to change anything.
Get access token, have to write down this token and put it in
travis ci
environment variables.Finally, run:
1 | git checkout hexo |
Travis ci
will be called automatically and automatically finish the deployment.