preface
In “A blog with VuePress + Github Pages”, we build a blog with VuePress and see what the final TypeScript Chinese document looks like.
This article explains how to optimize SEO.
1. To generate a sitemap
Generate a sitemap with vuepress-plugin-sitemap:
1.1 installation
yarn add vuepress-plugin-sitemap -D
Copy the code
1.2 change the config. Js
// .vuepress/config.js
module.exports = {
plugins: {
'sitemap': {
hostname: 'https://ts.yayujs.com'}}},Copy the code
1.3 If generation fails
If the build fails:
This may be because you set the lastUpdated or used @vuepress/last-updated plug-in. When the two are used together, an error is generated because of the time object. We search the issues of vuepress-plugin-sitemap. A solution can be found. Let’s modify config.js:
// .vuepress/config.js
module.exports = {
plugins: [['@vuepress/last-updated',
{
transformer: (timestamp, lang) = > {
return new Date(timestamp).toLocaleDateString(); }}], ['sitemap',
{
hostname: 'https://ts.yayujs.com'}}]]Copy the code
1.4 build successful
If the build is successful, we’ll see a sitemap.xml in the dist directory that looks something like this:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>https://ts.yayujs.com/learn-typescript/</loc>
<lastmod>The 2022-01-05 T16:00:00. 000 z</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://ts.yayujs.com/learn-typescript/handbook/ConditionalTypes.html</loc>
<lastmod>The 2022-01-05 T16:00:00. 000 z</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>
Copy the code
1.5 a sitemap address
When we deploy to the server, we can get a Sitemap address, such as mine:
https://ts.yayujs.com/learn-typescript/sitemap.xml
Copy the code
With such a Sitemap address, we can easily submit to various search engine platforms and crawl our pages according to sitemap.
2. Baidu included
2.1 Adding a Site
Log in to Baidu search resource platform and enter the user center:
Click “Add site”, you may need to complete the account information, and then enter the site information filling page, divided into three steps:
Step 1: Enter the site
Step 2: Site properties
Step 3: Verify the site
The reason why you need to verify the site is to prove that you are the owner of the domain name, after successful verification, you can quickly add sub-sites in batches, view all sub-site data, no need to verify sub-sites one by one.
Here I use HTML tag validation and modify the config.js file of vuepress according to the code instructions in the figure:
// config.js
module.exports = {
title: "title".description: 'description'.head: [['meta', { name: 'baidu-site-verification'.content: 'Fill in your code'}}]]Copy the code
Then click “Complete verification” and the following will appear:
Click on “I know” to jump to HTTPS authentication here:
After one day, the following information is displayed:
2.2 Submission for Inclusion
On the site management page, click “General Inclusion” :
Ordinary collection tools can actively push resources to Baidu search, shorten the time for crawler to find website links, and do not guarantee the collection and display effect.
There are three ways to submit data: API submission, Sitemap submission, and manual submission, so how to choose? Refer to the platform tool manual:
**API push: ** The fastest way to submit, it is recommended that you immediately push the new output links of the site to Baidu through this way, to ensure that the new links can be timely included by Baidu.
** Sitemap: ** You can periodically put website links into Sitemap and then submit sitemap to Baidu. Baidu will periodically grab and check the Sitemap you submit and process the links in it, but the inclusion speed is slower than API push.
** Manual submission: ** If you do not want to submit the link programmatically, you can submit the link manually to Baidu in this way.
Here I choose sitemap mode and fill in the sitemap address obtained in the previous section:
After submission, it will enter the waiting state:
2. 3. Smart refrigerator
3.1 Adding a Site
Visit search.google.com and if you haven’t added a site before, you’ll be asked to add it directly:
3.2 Verifying sites by DNS
Here I select “domain”, after entering the domain name, you will be asked to perform DNS authentication:
Since I bought the domain name in Wanwang, I directly visit the domain name console of Ali Cloud, and then select the corresponding domain name and click “resolve” :
Then click “Add Record” :
Select TXT as the record type and fill in the content provided by Google as the record value:
After the DNS is added, it takes a long time to resolve the DNS. Therefore, you are advised to wait a few minutes before performing the verification. After the verification is successful, the site will enter the background:
3.3 Submission for Inclusion
Click “Website Check” in the left navigation bar and enter the domain name to check. If it is not included in Google, click “Request indexing” :
After testing the indexability of the actual url, the following will appear:
3.4 Submit site map
3.5 Confirm inclusion
You can use site: domain in the Google search bar to check if your site is included in Google
4. 360
4.1 Adding a Site
Login 360 Webmaster platform:
4.2 Verifying a Site
4.3 Submit site map
5. Other platforms
In addition to these three platforms, there are also Bing webmaster, Sogou webmaster, what webmaster, operation is basically similar, not to say more.
series
Blog building series is the only practical series I have written so far. It is estimated to be about 20 articles, explaining how to use VuePress to build and optimize a blog and deploy it to GitHub, Gitee, private server and other platforms. This is the 27th article in a series at github.com/mqyqingfeng…
Wechat: “MQyqingfeng”, add me Into Hu Yu’s only readership group.
If there is any mistake or not precise place, please be sure to give correction, thank you very much. If you like or are inspired by it, welcome star and encourage the author.