This article is about how to generate a blog locally and deploy it to Github, as well as related commands. It may need to be continuously supplemented in the future. Most likely it will be delayed
I don't feel like writing anymore, it's not interesting to reinvent the wheel. You can refer to ARGVCHS's Hexo Blog Setup Tutorial II, and I'll just add a little bit here.
0. Initialize Hexo#
In the Git Bash of the Blog folder, enter the following commands in order:
hexo init # Initialize Hexo framework
hexo g # Generate static files locally
hexo s # Run static files locally
Wait until the console outputs the following content:
INFO Validating config
INFO Start processing
INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.
Open http://localhost:4000 to view the blog in the browser.
1. Hexo File Structure#
hexo/
|-- node_modules/ Used to store NPM packages, no need to pay attention to
|-- public/ Locally generated static files ready for deployment
|-- scaffolds/ Stores article templates used by hexo new
|-- source/ Stores articles and some resources
|-- themes/ Stores themes
|-- _config.xxx.yml Theme configuration file (replace xxx with the theme name)
|-- _config.yml Hexo's configuration file
|-- db.json
|-- package.json NPM package json, no need to pay attention to
|-- package-lock.json
2. Install Theme#
First, choose a desired theme from Hexo themes, and after selecting the theme, you need to install it. Run the following command in the root directory of the blog to clone the theme to your local machine:
git clone <theme-link>.git <theme-name> --depth=1 # <theme-link> is the theme link, <theme-name> is the theme name
For example, if my theme is ParticleX, it would be git clone https://github.com/argvchs/hexo-theme-particlex.git particlex --depth=1
After the installation is complete, set the theme parameter to your theme name in the _config.yml file in the root directory of the blog. This will allow you to switch themes. Generally, themes have introductions and configuration instructions on their GitHub project pages, so you can customize the pages according to the instructions.
3. Create About Page and Article Categories#
Categories/Tags Article Categories#
Enter hexo new page categories
to create the Categories page
Open the index.md file in source/categories and add type: categories before the article
Enter the command hexo new page tags to create the Tags page
Open the index.md file in source/tags and add type: tags before the article
If you want the title to be uppercase, you can change the title parameter to uppercase, for example, title: Categories. However, some themes detect based on the title and may not detect it.
About Page#
First, follow the method of creating article categories to create the About page, and then add content below it.
4. Common Hexo Commands#
Generate static files: hexo g
Clear static files: hexo cl
Run locally: hexo s
Deploy to website: hexo d
Generate static files and deploy to website: hexo d -g
or hexo g -d
Create a new article: hexo new [layout] <file>
P.S. The layout specifies the article layout. When set to draft, the article will be saved in the source/_drafts folder as a draft and will not be published. Use hexo publish
to publish.
P.S. The in the create new article command is the file name, and the title can be modified in the title parameter in the article.