Hexo is a fast, concise and efficient blog framework.Hexo Use
Markdown (or other rendering engine) parses the article and generates a static web page with beautiful themes in seconds.
Hexo is one of the most popular blog frameworks, so I'll try to do some basic functionality testing myself.The reason I chose the code cloud instead of GitHub is that I don't need GitHub Pages for my own VPS, so there are no tutorials on how to use GitHub Pages. The second reason is that private warehouses on GitHub are charged and free private warehouses can be created on the code cloud.Others choose to use Docker to create a blog environment and make a mirror backup. If you don't use this scheme here, it's OK for each!
Main Server System Version and Kernel Version:
[root@dbn-japan ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@dbn-japan ~]# uname -r 3.10.0-862.3.2.el7.x86_64
Test Server System Version and Kernel Version:
[root@host ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@host ~]# uname -r 4.10.4-1.el7.elrepo.x86_64
yum install -y wget
# Download the latest bin package for nodejs wget https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz # decompression xz -d node-v10.13.0-linux-x64.tar.xz tar -xf node-v10.13.0-linux-x64.tar # Move Directory mv node-v10.13.0-linux-x64 /usr/local/nodejs # Deployment File ln -s /usr/local/nodejs/bin/node /usr/bin/node ln -s /usr/local/nodejs/bin/npm /usr/bin/npm
OK to go Official website Download, the type I use here is: Linux Binaries (x64)
[root@dbn-japan packages]# node -v v10.13.0 [root@dbn-japan packages]# npm -v 6.4.1
If the version number is output, the installation is successful.
yum install -y git
git config --global user.email "email@example.com" git config --global user.name "BNDong"
npm install -g hexo-cli
Try to execute the command after installation: hexo
If the following output appears, solve it as I do below, and skip if none.
[root@dbn-japan packages]# hexo -bash: hexo: command not found
Edit the environment variable file: vim/etc/profile, adding the following settings at the end of the file:
Refresh the environment variable: source/etc/profile, and then run the command hexo to get the correct output.
Create Project Branch
Create a new branch:sources
- master: Stores static resources generated by Hexo compilation.
- sources: Store the source file to back up the blog.
Run the following command to create the SSH Key, and change the mailbox part to the mailbox you created when you created the account:
[root@dbn-japan blog.dbnuo.org]# ssh-keygen -t rsa -C "firstname.lastname@example.org" Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): # Catalog Enter passphrase (empty for no passphrase): # Enter a password to skip on return Enter same passphrase again: # Re-enter password
View public keys:
Add a public key to the code cloud.
Jump to the root directory of the site and clone the item locally:
git clone https://gitee.com/dbnuo/bnd-hexo.git
Jump to the extracted project directory:
# Create a hexo directory mkdir hexo # Enter the hexo directory cd hexo/ # Initialize the hexo directory hexo init npm install # Install Plugins npm install hexo-generator-index --save npm install hexo-generator-archive --save npm install hexo-generator-category --save npm install hexo-generator-tag --save npm install hexo-server --save npm install hexo-deployer-git --save npm install hexo-deployer-heroku --save npm install hexo-deployer-rsync --save npm install hexo-deployer-openshift --save npm install hexo-renderer-marked --save npm install hexo-renderer-stylus --save npm install hexo-generator-feed --save npm install hexo-generator-sitemap --save
First look at what's in the folder:
[root@dbn-japan hexo]# ls -a . .. _config.yml .gitignore node_modules package.json package-lock.json scaffolds source themes
- _config.yml: Site configuration files, need to be backed up;
- themes: Theme folder, need backup;
- source: the.md file of the blog post, which needs to be backed up;
- scaffolds: Template for article, need backup;
- package.json: Name of installation package, need backup;
- .gitignore: Limit which files can be ignored when push and need to be backed up;
- .git: Both the theme and the site have a logo that this is a git project and does not require a backup;
- node_modules: is the directory of the installation package, which is regenerated when npm install is executed, and no backup is required;
- public: is a static web page generated by hexo g and does not require backup;
- .deploy_git: As above, hexo g will also be generated and no backup is required;
- db.json: File, no backup is required.
Basic configuration is available for reference Official Documents Configuration instructions.Here you need to add the Git configuration at the end:
Run the command: After hexo Cl && hexo G-d enters the user name and password, the page code is submitted to the code cloud project.
Specify the site directory in the public folder of hexo to visit the site:
Jump to project directory bnd-hexo:
git checkout -b sources # Create Switching Branch git push origin sources # Submit code to branch
Submit to CodeCloud Project Branch:
Now that this is done, the code is backed up in the project.To test backup recovery, I created a new article, test, and submitted it for testing.
Switch to a test server where the basic installation and setup can refer to the above process.
Jump to the root directory of the website:
# Pull Items to Local git clone https://gitee.com/dbnuo/bnd-hexo.git # Jump to Directory cd bnd-hexo # Create branch and pull git checkout -b sources origin/sources # Jump to Source File Directory cd hexo # Initial Installation npm install npm install hexo-generator-index --save npm install hexo-generator-archive --save npm install hexo-generator-category --save npm install hexo-generator-tag --save npm install hexo-server --save npm install hexo-deployer-git --save npm install hexo-deployer-heroku --save npm install hexo-deployer-rsync --save npm install hexo-deployer-openshift --save npm install hexo-renderer-marked --save npm install hexo-renderer-stylus --save npm install hexo-generator-feed --save npm install hexo-generator-sitemap --save
After execution, hexo is restored and can operate normally.
So far both servers are working on a project library, which can be said to be multi-terminal. I have created a new article on the test server: hexo new post "test2"
Submit upload after successful creation.
Switch back to the primary server:
# Jump to Project Directory cd bnd-hexo # Pull Items git pull origin sources # Jump to Source File Directory cd hexo/ # Recompile hexo cl && hexo g -d
Visit the website again:
See here the article test2, at most terminal editing operations succeeded.
Here is a brief introduction to some necessary process operations. We recommend that you encapsulate some basic operations into scripts to operate. For topics and optimization, you can refer to some online resource tutorials. Thank you for reading. Thank you.
It's not easy to create. Give it a compliment!!
Copyright Statement: Articles are original on this site without special instructions. Please indicate where they were reproduced
Links to this article:https://blog.csdn.net/wsad861512140