Create blog
Pre-requirements
The blog framework used is Hexo
- A fast, simple & powerful blog framework!
- Powered by Node.js
The remote site used is Github Pages
Install the CLI(command-line interface) of Hexo via npm
1 | $ npm install hexo-cli -g |
Initialise Hexo
1 | $ hexo init <folder> |
More info: about npm install(with no args, in package dir)
Deploy to the remote server
Install hexo-deployer-git
1 | $ npm install hexo-deployer-git --save |
And then open the _config.yml
in the root directory
edit settings :
1 | deploy: |
Deploy to remote sites after generate static files
1 | $ hexo g -d |
or
1 | $ hexo d -g |
More info: about Generating and Deployment
At last
1 | # install sleepms, concurrently, open-cli first |
open the package.json
in the root directory,
and then add scripts to run hexo-cli
command line combination via npm,
Then just like:1
2
3
4
5
6
7
8
9
10"scripts": {
"deploy": "hexo clean && hexo g -d && open-cli https://yourname.github.io",
"serve": "hexo clean && concurrently \"hexo server -p 1314\" \"hexo g -w\" \"sleepms 5000 && open-cli http://localhost:1314/\""
},
// ...
"devDependencies": {
"concurrently": "^3.6.1",
"open-cli": "^6.0.0",
"sleep-ms": "^2.0.1"
}
More info :
- about hexo clean and hexo server
- about concurrently
generate files, deploy and browse site online
1 | $ npm run deloy |
generate files, watching changes and use local server to browse page
1 | $ npm run serve |
More info :
- if when you run hexo server and the port is occupied, you can try to stop the occupied port manually, (Windows OS can do so)
- Using git deployer, so the deployment should be through Git Bash, and if execute
npm run dist
error thatfatal: Unable to create 'path/.git/index.lock': File exists.
, check to see if.deploy_git
already exists, delete it and executenpm run dist
again.
Q&A
If you encounter the following problems
1 | TypeError [ERR_INVALID_ARG_TYPE]: The "mode" argument must be integer. Received an instance of Object |
Please switch to the old version of node
, such as 12.4.0
Postscript:
Customize the pretty style, configure the local search, add comment and so on by the powerful and interesting third party theme NexT,
Through a variety of technical to add a variety of plugins…
The blog was born O(∩ _ ∩)O~