Hexo introduction
- hexo.io
- hexo.io/zh-cn/
Environment to prepare
Install nodejs
- Download it at nodejs.org/en/
- The following uses node-v14.17.1.pkg as an example
Open the terminal and switch to the root user
For example, start the terminal or iterms software and run the following command
// Switch to root user sudo suCopy the code
Install Taobao image
/ / use NPM to install relevant dependent packages, speed is slow, suggest installation taobao mirror, subsequent command USES CNPM NPM install - g CNPM - registry=https://registry.npm.taobao.orgCopy the code
Install Hexo
Hexo CNPM install -g hexo-cliCopy the code
Hexo is successfully installed
Initialize the blog site
Create a project folder and enter it
For example: Blog. If the project has problems later, or you want to create it again, just delete this folder
Sudo hexo init sudo hexo initCopy the code
Start the hexo
// Start hexo hexo sCopy the code
Open your browser to the blog site
// Open the browser at http://localhost:4000Copy the code
Create and write a blog
- The Vim command can be used here
// Create the article hexo n "my first blog post" // Edit the article vim my first blog post. MdCopy the code
Project management execution
Clearing the project cache
- This command is used to add blog posts or modify blog posts
// Clean up the previously generated site hexo CleanCopy the code
Rebuild the project
// Rebuild the blog project hexo GCopy the code
Start the project again
// Launch the blog hexo s againCopy the code
Modify the theme
Choose a topic
You can download the theme according to your own needs. For example, choose Butterfly
Download the theme code
- In the project root directory, the “Blog “folder, execute the following command,
/ / clone theme code to themes/butterfly git clone https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterflyCopy the code
Modify the project configuration file to configure the topic
// Modify the configuration file, subject subject vim _config.ymlCopy the code
Execute the following command in the project directory
This pit solution from here: zhuanlan.zhihu.com/p/137946156
npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive
Copy the code
Rebuild the project
- The specific operation process has been described in previous chapters
hexo clean
hexo g
hexo s
Copy the code
Rerun the project
New theme interface
You can modify the theme interface and optimize the interface according to your own requirements.
Deploying blogs to the cloud (GitHubYou need to have your own account)
The new warehouse
To create a new repository, the repository must be public.
Warehouse address for successfully creating this case:
https://github.com/CodingDGSun/CodingDGSun.github.io.git
Copy the code
Execute the following command in the project directory
cnpm install --save hexo-deployer-git
Copy the code
Modifying a Configuration File
// Modify the configuration vim _config.ymlCopy the code
Modify the last location of the file where [repo] fill in the newly created warehouse address.
type: git
repo: https://github.com/CodingDGSun/CodingDGSun.github.io.git
branch: master
Copy the code
Deploy the project to the cloud
// Run the hexo d deploy commandCopy the code
Visit the cloud Blog home page
The access address is https://name of the new repository +.github. IO. For example, codingdgsun.github