Finally completed the setup, optimization, and deployment of the Hexo blog. Although I encountered various problems during the process, I managed to solve them to some extent. Below are some relatively long-standing issues and their solutions. Other minor issues encountered are not listed one by one.
In summary: ① Make good use of search engines (Baidu / Google) ② Study the official documentation ③ Think and practice more.
Domain Name Resolution Issues:#
Issue 1: Unable to access or redirected to domain registrar after domain name resolution to Dnspod
- Reason: The domain purchased by the blogger from Namesilo comes with 4 default DNS resolution records.
Solution: Delete the default DNS resolution records and set one or two A records (can be viewed on Github
or ping username.github.io
yourself) pointing to the IP in Dnspod, and set one CNAME
record pointing to the username.github.io
domain.
Access Speed Issues:#
Issue 1: Slow loading of site after adding Valine
Reason: The default CDN address
unpkg.com/valine/dist/Valine.min.js
of theValine
comment system loads too slowly.Solution: Replace the default CDN address in
\themes\next\layout\_third-party\comments\valine.swig
with the latestValine.min.js
address.
Latest Valine.min.js address: https://www.jsdelivr.com/package/npm/valine, obtain it as shown in the following image:
SEO Issues:#
Issue 1: Unable to verify site on Baidu Webmaster Platform
Reason: Baidu cannot find the verification file or the verification file has been rendered by the Hexo template and its content has changed (this is the situation the blogger encountered, the content of the file was rendered and modified in github)
Solution: Use file verification, place the specified html file in the source directory, and add
skip_render: baidu_verify_******.html
to the site configuration file.
Issue 2: If the article title contains Chinese characters, the default blog article link contains Chinese characters
Reason: The Permalink in the site configuration file is set to:
posts:/:year/:month/:day/:title/
Solution: Install the plugin
npm hexo-abbrlink --save
, configure the site file according to the plugin documentation, and the plugin will optimize the blog article link to a 3-level link format without Chinese characters.
Blog Backup and Restoration#
Blog Backup#
$ git init //initialize git
$ git add . //add git files
$ git commit -m "init" //git commit
$ git pull origin hexo //pull to hexo branch
$ git push origin hexo //push to hexo branch
Blog Restoration#
(1) Configure ssh connection to Github
$ cd ~/.ssh or cd .ssh //check if ssh key is set on the local machine
$ cd ~ //if there is no ssh, switch the current path to "~"
$ ssh-keygen -t rsa -C "[email protected]" //replace with your own email address, generate ssh key after three enter key presses; add id_rsa.pub content to Github;
$ git config --global user.name “your_username” //set username
$ git config --global user.email “your_registered_github_Email” //set email address (recommended to use the email registered with github)
$ ssh -T [email protected] //test if ssh key is set successfully
(2) Install Node.js; Git; Hexo;
$ git clone -b hexo [email protected]:user/user.github.io.git //clone the hexo branch from Github to the local machine
$ cd user.github.io //switch to the hexo directory
$ npm install hexo
$ npm install
$ npm install hexo *** //install required plugins: feed;deployer;abbrlink;sitemap;pdf;nofollow;baidu-url-submit, etc.
$ hexo g -d //test if it can compile and upload properly
Plugins Installed by the Blogger:#
hexo-abbrlink // Hexo link optimization
hexo-baidu-url-submit // Baidu link submission
hexo-blog-encrypt // Blog article encryption
hexo-autonofollow // Outbound link optimization
hexo-deployer-git // Upload deployment
hexo-generator-baidu-sitemap // Baidu site map
hexo-generator-feed // RSS plugin
hexo-generator-searchdb // Site search
hexo-generator-sitemap // Site map
hexo-neat // Blog compression
hexo-pdf // Blog article PDF display
hexo-wordcount // Counting plugin
hexo-lazyload-image // Image lazy loading