This is the second day of my participation in the November Gwen Challenge. Check out the details: the last Gwen Challenge 2021
This article describes how to build a personal blog, but in order to make their own blog have more traffic, more exposure, or not enough, let’s talk about how to optimize their own blog.
1. Multiple machines
Sometimes you need to blog in a different place. This requires synchronizing the blog across multiple machines.
The idea is to create two branches, one for managing blogs and one for managing raw files
In the blog directory
1.1 Creating a Source Git Directory
Git init git remote add origin / / https://github.com/xx/xx.github.io to fill in your 'addressCopy the code
1.2 Creating the Source branch
git checkout -b source
git add .
git commit -m 'add source'
git push origin source
Copy the code
1.3 Synchronizing Multiple Machines
Clone warehouse to local
Initialize Hexo. Do not repeat the steps above. Note the switch of branches
2 Categories & labels
2.1 Creating a Category
perform
hexo new page categories
Copy the code
Open source/categories/index, md
Is amended as:
-- Title: Article category Date: 2017-05-27 13:47:40 Type: "Categories" --Copy the code
2.2 Add categories to articles
-- Layout: Hexo Title: Hexo + Material + GithubCopy the code
3. SEO optimization part (supplement)
Since the blog is connected to Google and Baidu search, we have done some SEO optimization.
3.1 Site Map
Install plug-in:
npm install hexo-generator-sitemap --save
npm install hexo-generator-baidu-sitemap --save
Copy the code
Modify the _config.yml configuration file of the blog to add the following
# # If your site is put in a subdirectory, set the url as' http://yoursite.com/child 'and root as child/'/' # replaced with your own domain url: https://www.zdran.com ... . Plugins: - hexo-generator-baidu-sitemap - hexo-generator-sitemap baidusitemap: path: baidusitemap.xml sitemap: path: sitemap.xmlCopy the code
Then submit it to Baidu and Google, and it will be searched regularly
3.2 Baidu submits URL
The URL submitted to Baidu requires manual processing, which can be done using the hexo-Bidu-URL-submit tool.
Installation:
npm install hexo-baidu-url-submit --save
Copy the code
Then add the following configuration to _config.yml:
Host: www.hui-wang.info ## Your_token ## Please note that this is your secret key, so please do not publish the blog source code in a public repository! http://www.baidu_url_submitter ## This is a new url that will be stored in the directory containing the new link deploy: -type: baidu_url_submitter ##Copy the code
The original address
4.3 robots file
Create a new robots.txt file in \source, refer to the following:
User-agent: *
Allow: /
Allow: /archives/
Allow: /categories/
Allow: /tags/
Disallow: /vendors/
Disallow: /js/
Disallow: /css/
Disallow: /fonts/
Disallow: /vendors/
Disallow: /fancybox/
Sitemap: https://zdran.com/sitemap.xml
Sitemap: https://zdran.com/baidusitemap.xml
Copy the code
Please change the domain name to your own domain name!!
Submit robots files to Google and Baidu