hexo-submit-urls-to-search-engine Documentation

中文版文档

My native language is not English, if there are any inaccuracies, please contact me, thank you!

hexo-submit-urls-to-search-engine is a plugin which can submit the new link of the Hexo to Google, Bing, Baidu search engine, that make search engines index your pages earlier.

For example, I publish an article, in 5 minutes, I can find it in Bing. Well done!

These three major search engines have occupied 97% of the global search engine market share (including Yahoo, ecosia using bing index). Later, I may add the function of submitting links to Yandex.

Github

Telegram group: https://t.me/hexoseo

Register each webmaster platform

All “record” in this section are filled into hexo’s _config.yml,please use the format given below

Baidu

Baidu is a Chinese search engine. Please visit: https://cjh0613.com/20200603HexoSubmitUrlsToSearchEngine.html

Bing

Bing webmaster platform has new and old sites.

  1. Register, login Bing new webmaster platform( https://www.bing.com/webmasters
  2. Add your site
  3. Click on Settings button on top right corner and then go to API Access section.
  4. Click on Generate API Key to create an API Key. Only one API key can be generated per user. Record the API key.

Google

One of the biggest problems with Google Webmaster Tools is its lack of a complete API to programatically submit updated URLS for indexing. At the moment, Google’s Indexing APIonly allows submission of pages with specific kinds of structured data – JobPosting or BroadcastEvent embedded in a VideoObject.

But I still push my links to google. How does Google know your page doesn’t contain JobPosting or BroadcastEvent if it doesn’t crawl it? If they’ve crawled it, even if they don’t find JobPosting or BroadcastEvent, what’s the reason to waste resources and discard information that’s already captured? Since they’re using it, we’ve achieved our goal. In actual use, Google doesn’t seem to have downgraded my site either. Maybe Google forgot to change the documentation? As far as I can tell there are two serious errors in Google’s document that haven’t been corrected in years.

Google webmaster platform also has new and old sites. Please follow Google Indexing API Documentationto configure.

steps:

  1. Please follow Google Indexing API Documentationto configure.
  2. Only use the new search console, it is impossible to set your service account, please use the old Webmasters tool ,add the email to the old Webmasters tool.
  3. Put the json file of the google key in the root directory of the website (same location as the hexo _config.yml file)

Configure hexo

1.install

Please run in the hexo root directory:

1
npm install --save hexo-submit-urls-to-search-engine

2.Edit hexo _config.yml

(1)hexo_submit_urls_to_search_engine

Configure the hexo-submit-urls-to-search-engine plugin, paste the following into _config.yml of hexo.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
hexo_submit_urls_to_search_engine:
submit_condition: count # Submitted condition, optional value: count | period, Now only supports count
count: 10 # Submit the latest 10 links
period: 900 # Submit a link with a modification time of 900 seconds
google: 0 # Whether to submit to Google, optional values: 1 | 0 (0: No; 1: Yes)
bing: 1 # Whether to submit to bing, optional value: 1 | 0 (0: no; 1: yes)
baidu: 1 # Whether to submit to baidu, optional value: 1 | 0 (0: no; 1: yes)
txt_path: submit_urls.txt ## The address of the text document, the link to be pushed will be saved in this text document
baidu_host: https://cjh0613.github.io ## Domain name registered in Baidu webmaster platform
baidu_token: xxxxx ## Please note that this is your secret key, so do not publish the website source code in the public repository!
bing_host: https://cjh0613.github.io ## Domain name registered in Bing webmaster platform
bing_token: xxxxx ## Please note that this is your secret key, so do not publish the website source code in the public repository!
google_host: https://cjh0613.github.io ## Domain name registered in Google webmaster platform
google_key_file: Project.json # Store the json file of the google key in the root directory of the website (same location as the hexo _config.yml file), please do not publish the source code of the website in the public warehouse!
google_proxy: 0 # Set the proxy used to submit urls to Google
replace: 0 # Whether to replace some substrings in links, optional value: 1 | 0 (0: no; 1: yes)
find_what: http://cjh0613.github.io/blog
replace_with: https://cjh0613.com

Comment

  • submit_condition: supports two ways to judge whether to submit a link, namely count | period. Apply the following count | period configuration items respectively
  • period: A period of time, in seconds. If the difference between the update time of the article and the running time of this plugin is less than this value, the link will be submitted. For example: there are two files a.html and b.html, corresponding to https://yoursite.com/a.html and https://yoursite.com/b.html, and their update time is the same as this plugin The difference between the running time is 800s and 1000s (period field is set to 900), then https://yoursite.com/a.html will be submitted, https://yoursite.com/b.html will not
  • google_proxy: If you can use google API, just keep this as 0. Use what http proxy to submit urls to google. Google API is blocked in China mainland, so,…
  • replace: Whether to replace some substrings in links, it can fix some problems caused in generating urls.

note
Of course, you can use environment variables to record the key, so that even if the source code is placed in a public warehouse, it will not reveal the secret key.
Only supports Baidu and Bing to set environment variables now.
Steps:

  1. Edit the hexo’s _config.yml:
1
2
3
hexo_submit_urls_to_search_engine:
baidu_token: 0
bing_token: 0
  1. Set the environment variables BAIDU_TOKEN, BING_TOKEN
  2. If you are using Github Action, you will also need to set the environment variables in the .yml file, as shown in the following example
  3. Run hexo clean && hexo generate && hexo deploy and enjoy!
1
2
3
4
5
6
7
8
9
- name: xxxx
env:
BAIDU_TOKEN: ${{ secrets.BAIDU_TOKEN }} # !!!!!
BING_TOKEN: ${{ secrets.BING_TOKEN }} # !!!!!
run: |
npm i -g hexo-cli # install hexo
npm i
……
hexo deploy

I put Google’s .json key file in a private repo, then clone it to the public repo for use:

1
2
3
4
hexo generate
git clone https://cjh0613:${Token}@github.com/cjh0613/${private_repo}.git tem
cp ./tem/Project.json Project.json
hexo deploy

After completing the above configuration, when you run the hexo generate command in the Hexo root directory, a .txt file will be generated to store the link to be pushed.

You can open this file to check whether the link is correct, if not, please open the _config.yml of hexo to configure. You can also manually modify this .txt file before pushing the link.

(2)deploy

If you have not added the deploy: configuration item before, paste the following directly into the _config.yml of hexo:

1
2
3
4
deploy:
- type: cjh_google_url_submitter
- type: cjh_bing_url_submitter
- type: cjh_baidu_url_submitter

After completing this step, you can automatically submit the links to the search engine when you run the hexo deploy command. Of course, you need to run hexo generate to generate the latest .txt file to store the links to be submited.

If you can submit successfully, please go to Github to Star this repo, thank you!

If the deploy: configuration item has been set, directly pasting the above code block will prompt Configuration conflict, just add it under the existing deploy: configuration item. Such as:

1
2
3
4
5
6
7
8
9
10
deploy:
- type: git
repo:
coding: git@xxx
branch: master

# Add configuration items of this plugin:
- type: cjh_google_url_submitter
- type: cjh_bing_url_submitter
- type: cjh_baidu_url_submitter

Note: There is a - before each type: above

finish

Run:

1
hexo clean && hexo generate && hexo deploy

And enjoy!

If you can push successfully, please go to Github to click Star as support, thank you!

update the plugin

After you install this plugin, please watch this project from Github to get the plug-in upgrade prompt (choose Releases only to get the upgrade prompt only, choose Watching will also push Issues, Pull requests, etc., sent by email)

Releases only

If there is a new version of this plug-in, please run in the hexo root directory:

1
npm update --save hexo-submit-urls-to-search-engine

response

success response:

1
2
3
4
5
6
7
8
9
10
Bing response:  { d: null }
Baidu response: {"remain":2999,"success":1}
Google response: { urlNotificationMetadata:
{ url:
'https://cjh0613.github.io',
latestUpdate:
{ url:
'https://cjh0613.github.io',
type: 'URL_UPDATED',
notifyTime: '2020-06-12T05:37:25.701779228Z' } } }

References

The following is not complete… Some of them have no time to record, and I also refer to the articles I wrote before and their reference materials.

(You can also visitarchiveto look for posts)