A server I rented a year ago expired, and a blog system developed by myself was deployed on it before the expiration, but I forgot to transfer data, so the blog cannot be accessed temporarily.

Then came Hexo, a static blogging framework that you could use to back up your blog so that you had a temporary site to access in the event of server problems.

1 installation

According to the documentation on the official website, there are two installation methods.

Install the COMMAND line tool NPM install -g hexo-cli

NPM install hexo NPX hexo

I’m using the first option here because the second option is 😂, which is available to Advanced users

Once the command-line tool is installed, it is ready to run in the appropriate place

hexo init Hexo
Copy the code

Hexo is the blogs folder, where the local blogs are placed.

2 Modifying Configurations

The blog directory is shown in the figure.

Next, modify the blog configuration in _config.yml, such as the blog name, address, profile, and so on.

If you want to add a little TAB bar icon to your blog, you can put it in the Source folder in your blog root directory and rename it favicon.png.

Pay attention to,timezoneIf it’s gonna change, it’s gonna changeAsia/Shanghai

3 Setting a Theme

A good blog, certainly need to have a beautiful appearance.

The default theme is more elegant, but less concise. Later, you can customize a Hexo theme to suit your needs.

4 One-click deployment

4.1 installationhexo-deployer-git

npm install hexo-deployer-git --save
Copy the code

4.2 Configuring Deployment Rules

In _config.yml, find the deploy configuration item

deploy:
	type: git
	repo: ' '
	branch: gh-pages
	message: "Site updated: {{ now('YYYY-MM-DD HH:mm:ss') }}"
Copy the code

Where repo is set to the address of the repository on Github where you will be storing your blog.

4.3 Clearing and Deployment

hexo clean
hexo deploy
Copy the code

The cleanup operation will delete the previously generated public folder; The deployment generates a new public folder and pushes it to the Gh-pages branch of Github.


This successfully deployed the Hexo blog. This way, you can back up your blog content over the network, and if the server goes down, you can use a backup blog first.