Skip to main content

Automatically Submit Docusaurus URLs to Search Engines

🤖WARNING
The English translation was done by AI.

In the past, when using Hexo, there were third-party packages available. So I did some research and found that Docusaurus does not have a similar third-party package. Therefore, I wrote a generic Github Action called search-engines-urls-push, which can be used as long as your website has a sitemap.

Usage

Prerequisite

Your website has already generated a sitemap.

Create Github Action

Create a Github Action for your project with the following content.

info

You can configure the trigger conditions according to your own needs. For trigger condition examples, refer to Docusaurus DocSearch Setup.

name: search-engines-urls-push

on: deployment

jobs:
search-engines-urls-push:
runs-on: ubuntu-latest
name: search-engines-urls-push
steps:
- name: search-engines-urls-push
id: search-engines-urls-push
# Use the latest version
uses: 3Alan/search-engines-urls-push@v0.2.2
with:
site: ${{ secrets.SITE }}
sitemap: ${{ secrets.SITEMAP }}
count: ${{ secrets.COUNT }}
bing-token: ${{ secrets.BING_TOKEN }}
baidu-token: ${{ secrets.BAIDU_TOKEN }}
google-client-email: ${{ secrets.GOOGLE_CLIENT_EMAIL }}
google-private-key: ${{ secrets.GOOGLE_PRIVATE_KEY }}

Configure Actions secrets

Create the following Actions secrets in your project repository.

NameDescriptionRequired
SITEWebsite URLtrue
SITEMAPSitemap URLtrue
COUNTNumber of URLs to submit, if not provided, all will be submittedfalse
GOOGLE_CLIENT_EMAILclient_emailfalse
GOOGLE_PRIVATE_KEYprivate_keyfalse
BING_TOKENBing API Keyfalse
BAIDU_TOKENBaidu tokenfalse

For specific parameter options, refer to the action search-engines-urls-push documentation. Feel free to give it a star and contribute to the code.

If your daily quota for bing is larger than the total number of URLs you are submitting, please ignore this warning.

If you have configured a BING_TOKEN, then the COUNT value should be less than 10, as the daily quota for BING is only 10 URLs (most small traffic websites will have 10 URLs). Submitting more than 10 URLs will result in the failure of all URL submissions.

Daily quota for each platform (just for reference, it may vary for each person)

Baidu: 3000

Bing: 10

Google: 200

TODO

Generate a sitemap for the last 10 updated articles in Docusaurus

The original idea was to submit only the last 10 updated articles each time (based on the date field), as repeated submissions not only consume quota but may also affect SEO. However, due to the inability to customize the generation rules of the sitemap plugin in Docusaurus, I tried modifying the source code before and found that the Docusaurus postBuild lifecycle API exposed limited URL information (only one URL...), making it impossible to access the introduction information of each article.