This is the 5th day of my participation in the August More Text Challenge
All about Hexo — My Hexo column
Zero foreword
SEO is Search Engine Optimization.
It is a way to use search engine rules to improve the site’s natural ranking within the relevant search engines.
Following on from domain binding, in this article we will talk about how to find your Hexo blog on Baidu. Because the content is too long, it is divided into two parts, mainly about:
A Solution
Since Baidu cannot crawl GitHub content, we need to find a code hosting platform that baidu can crawl and provide Pages service.
Then we only have two domestic platforms to choose from: Gitee and Coding 🙈
Although these two things cost money, but Gitee custom domain name more than 90 can buy a server, Coding is free for the first six months, after a month may be a few cents (if few people visit), it is a natural choice of Coding platform.
In addition, we can use Github + Coding dual deployment, domestic IP access to domestic Coding address, foreign IP access to Github address, of course, we can bother to only Coding.
Coding website
After registering, create a Git project and select web hosting in continuous Deployment (see the Help center for details).
The second deployment
-
To deploy your blog to both repositories, add your project address to the root directory configuration file _config.yml:
 deploy:  - type: git  repository: [email protected]:username/username.github.io.git  branch: master  ​  # Your coding project address  - type: git  repository: [email protected]:username/username.git  branch: master    # note that the two usernames may be different Copy the code
-
Then go to the domain console, configure two CNAME resolution, enter your Coding project address in Baidu, enter your github. IO address in default:
-
Also bind your domain name under the Coding site Settings.
-
Then test whether Baidu can crawl to your website and type in the command line:
The curl - A "Mozilla / 5.0 (compatible; Baiduspider / 2.0; + http://www.baidu.com/search/spider.html) "- o example. HTML your domain nameCopy the code
-
In the command line directory, a file example.html is generated:
Baidu Included
-
It is impossible to search baidu after the site is just built. We can search site: your domain name and submit the website to Baidu:
-
After submission, click Add Website in Baidu Site Management, enter the domain name, and use CNAME to verify the website in the last step:
-
Add the above records to domain name console resolution:
-
Validation is complete and successful.
Four push resources
The last step we successfully let Baidu know the existence of the website, but Baidu does not know the content on our website, so to Baidu included push our content.
There are four methods: API submission, active push, Sitemap, automatic push, and manual submission.
Because manual submission is to copy and paste all the links in your blog into this interface for submission, I won’t go into details here.
API to submit
-
Find the line in this screen and run the command as prompted:
-
Success is returned after execution.
Take the initiative to push
-
NPM install hexo-bidu-url-submit –save
-
Open the site profile and add at the end:
 # add in the deploy TAB  deploy:  - type: baidu_url_submitter  ​  # Baidu actively push plug-ins  baidu_url_submit:  count: 80 # submit the latest link  host: www.heeh.xyz Your domain name  token: xxxxxxx  path: baidu_urls.txt The address of the text document in which the new link will be saved Copy the code
-
Where the token is obtained in the previous API submission:
-
The new link will be automatically pushed each time the hexo d is executed.
sitemap
-
Install plug-in:
 npm install hexo-generator-sitemap --save  npm install hexo-generator-baidu-sitemap --save Copy the code
-
After installation, hexo CL and hexo G-d will generate sitemap. XML (for other search engines) and baidusItemap. XML (for Baidu) files in the public directory.
-
Once you have the baidusItemap. XML file, go to this screen and submit:
- After submission, the web page will show success status.
Automatic push
-
Some topics support automatic push of Baidu search, which can be modified in the theme profile, such as matery:
 # Baidu search resource platform to submit links  baiduPush: true Copy the code
-
If not, add it to every HTML page that needs to be crawled by Baidu:
 <script>  (function(){    var bp = document.createElement('script');    var curProtocol = window.location.protocol.split(':') [0];    if (curProtocol === 'https') {      bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';   }    else {      bp.src = 'http://push.zhanzhang.baidu.com/push.js';   }    var s = document.getElementsByTagName("script") [0]; s.parentNode.insertBefore(bp, s); }) (); </script>Copy the code
V. Sum up
In general, the automatic method is a little better and more efficient than the manual method.
- Automatic way of active push is the fastest one, every day output of new links can be pushed to Baidu collection through this way.
- Automatic push is the most convenient, when the deployment code page is visited will be automatically pushed to Baidu included.
- Sitemap submission, Baidu will periodically grab check, so the inclusion speed is the slowest.
So in general I recommend active + automatic use together.
More practical content will be updated in the next post
More interesting articles: Mancuoj’s homepage – Articles – Nuggets (juejin. Cn)