Create a Github repository
Fill in warehouse information
The name of the warehouse needs to correspond to your account, such as Linxunfeng.github. IO Enter the basic information and click the green button below to create the warehouse.
Install Hexo
You need to install Node.js and Git on your computer
- Node.js: to generate static pages, download the latest version of the corresponding platform from the node. js website and install it along the way.
- Git: Commit local hexo content to Github. If you don’t have it installed, check out this tutorial.
Next, install hexo terminal input :(sudo must be added, otherwise permissions will fail)
sudo npm install -g hexo
Copy the code
CD to the folder where you want to store your blog, such as the hexo folder I have in gitHub on my desktop
Since this folder will be where you store your code in the future, it is best not to leave it lying around.
cd /Users/username/Desktop/gitHub/hexo
Copy the code
Then type [hexo init] in the terminal to initialize it, and Hexo will automatically download some files to this directory
hexo init
Copy the code
The structure of the directory after initialization is shown
Start the Hexo
// Enable local preview service hexo sCopy the code
Open it in your browser as prompted
http://localhost:4000/
Copy the code
Configuration Hexo
Open _config.yml, slide to the bottom, and change the contents of deploy to the one shown in the figure
deploy:
type: git
repository: https://github.com/LinXunFeng/linxunfeng.github.io.git
branch: master
Copy the code
The values for repository can be copied here, or you can modify the configuration yourself
Note: The configuration file for hexo (not just _config.yml) must be followed by a space whenever [:] appears, otherwise an error will be reported
Generating static pages
Hexo g // Hexo generateCopy the code
If the following error occurs:
ERROR Local hexo not found in ~/blog
ERROR Try runing: 'npm install hexo --save'
Copy the code
Then run the following command:
npm install hexo --save
Copy the code
If no error is reported, ignore this step.
There will be a public folder in the directory that will hold the static page we just generated
Uploaded to the lot
Hexo deploy // or hexo dCopy the code
If an error occurs after the command is executed
Deployer not found: github 或者 Deployer not found: git
Copy the code
Then we need to install another plug-in:
npm install hexo-deployer-git --save
Copy the code
After installing the plugin, perform hexo D and it will start uploading all the files in the Public folder to your gitHub repository
If you have not previously associated with Github, you will be prompted to enter the Github user name and password when you run the hexo deploy command
The browser to open the url/linxunfeng. Making. IO/page like http://localhost:4000, https://linxunfeng.github.io here with your own name of warehouse
Published articles
Terminal CD to your blog folder, run the following command to create a new post:
hexo new "postName"
Copy the code
A file named postname.md will be built under /blog/source/_posts.
Once the post is edited, run the terminal CD to your blog folder and execute the following two commands:
Hexo generate // Generate static pages hexo deploy // deploy articles to GithubCopy the code
Install the theme
Go to the Hexo theme page to find your favorite theme, using NexT.Muse as an example.
// clone the hexo-theme-next theme to the./themes directory and rename it next gitclone https://github.com/iissnan/hexo-theme-next themes/next
Copy the code
Then execute the following command (each step of deploying the article) :
// Clean cache files (db.json) and generated static files (public) hexo clean // Generate cache and static files hexo g // redeploy to server hexo dCopy the code
Yml file and./themes/next/_config.yml file, don’t forget the colons: followed by Spaces. Please refer to the NexT usage documentation for details.
Question tips
When encountering some puzzling problems, you can try executing the following command first:
sudo npm install
Copy the code
Problematic behavior such as changing an MBP; Accidentally performed hexo init, etc.
For example, when performing hexo G to generate static pages and hexo S to enable local preview, the page only appears
Cannot GET /
Copy the code
What do you notice missing from the files generated under the publish folder