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
2<object data="./Poster_ADL-AI_final.pdf" type="application/pdf" width="100%" height="877px">
</object> - Insert images to post:
1
![comment.png](comments.png)
Git push local gh-pagesrepository to remote repository
1
2
3$ git add .
$ git commit -m "update information"
$ git pushFinally, 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
2$ cd hexo
$ git clone https://github.com/theme-next/hexo-theme-next themes/nextSet 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
2
3
4
5
6
7canvas_nest:
enable: true
onmobile: true # Display on mobile or not
color: "100,100,100" # RGB values, use `,` to separate
opacity: 0.5 # The opacity of line: 0~1
zIndex: -1 # z-index property of the background
count: 99 # The number of linesAdd visitor comment, modify
themes/next/_config.yml
, first register a count in Disqus:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20# Multiple Comment System Support
comments:
# Available values: tabs | buttons
style: tabs
# Choose a comment system to be displayed by default.
# Available values: changyan | disqus | disqusjs | gitalk | livere | valine
active: disqus
# Setting `true` means remembering the comment system selected by the visitor.
storage: true
# Lazyload all comment systems.
lazyload: true
# Modify texts or order for any navs, here are some examples.
nav:
disqus:
# Disqus
disqus:
enable: true
shortname: <your-disqus-id> #
count: true
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
2
3
4deploy:
type: 'git'
repo: git@github.com:wang-yuhao/wang-yuhao.github.io.git
branch: masterwhen there is
Deploy error
:1
npm install hexo-deployer-git --save
generate and deploy
1
2hexo clean && hexo generate
hexo deployImportant: 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
2
3
4deploy:
type: 'git'
# repo: git@github.com:wang-yuhao/wang-yuhao.github.io.git
branch: gh-pagesIn local blog directory create a folder with name
.travis.yml
, it exists in the same directory with_config.yml
.Input this command:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18sudo: false
language: node_js
node_js:
- 12
cache: npm
branches:
only:
- master # build master branch only
script:
- hexo generate
deploy:
provider: pages
skip-cleanup: true
github-token: $GH_TOKEN
keep-history: true
on:
branch: master
local-dir: public
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
2
3
4
5git checkout hexo
hexo new "my first blog"
git add .
git commit -am"add a new blog"
git pushTravis ci
will be called automatically and automatically finish the deployment.