Skip to content

How to Customise Your Workflow Parameters#

Using the flexible parameters, you can submit individual or multiple URLs, or even entire or partial sitemaps, to IndexNow on a regular basis. Find out how based on the following example:

.github/workflows/submit_sitemap_to_index_now.yml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
name: Submit Sitemap URLs to IndexNow

on:
  schedule:
    - cron: 0 0 1 * *  # Run at midnight UTC on the 1st day of each month.

jobs:
  submit-sitemap:
    runs-on: ubuntu-latest
    steps:
      - name: Submit sitemap URLs to IndexNow
        uses: jakob-bagterp/index-now-submit-sitemap-urls-action@v2
        with:
          host: example.com
          api_key: ${{ secrets.INDEX_NOW_API_KEY }}
          api_key_location: https://example.com/${{ secrets.INDEX_NOW_API_KEY }}.txt
          endpoint: naver, seznam, yep
          urls: https://example.com
          sitemap_locations: https://example.com/sitemap.xml
          sitemap_filter: section1
          sitemap_days_ago: 2
          retries: 3

Overview#

Parameter Required Description Default
host Yes The host of your website, e.g. example.com. None
api_key Yes The API key for IndexNow, e.g. a1b2c3d4. None
api_key_location Yes The location of the API key, e.g. https://example.com/a1b2c3d4.txt. None
endpoint Optional One or more search engine endpoints, e.g. seznam or naver, seznam, yep. Multiple endpoints are tried in order. bing
urls Optional The URL(s) to be submitted, e.g. https://example.com. None
sitemap_locations Optional The location of the sitemap(s), e.g. https://example.com/sitemap.xml. None
sitemap_filter Optional Only submit sitemap URLs that contain the filter string, e.g. section1. None
sitemap_days_ago Optional Only submit sitemap URLs that have been modified recently based on the <lastmod> tag, e.g. 1, 2, or more days ago. None
retries Optional Number of times to retry a request on temporary errors, e.g. dropped connections or server errors. 0

Parameters#

host#

Contains the domain (and subdomain) of your website. Required every time you submit any URLs or sitemaps to the IndexNow API.

For example, if the URL to your sitemap is https://example.com, then the host parameter should be example.com:

.github/workflows/submit_sitemap_to_index_now.yml
14
          host: example.com

Or if your website URL is https://www.example.com, then the host should be www.example.com:

.github/workflows/submit_sitemap_to_index_now.yml
14
          host: www.example.com

api_key#

The API key for IndexNow, e.g. a1b2c3d4. Required every time you submit any URLs or sitemaps to the IndexNow API.

You need to set an API key on your website to verify ownership of your domain. This should be kept secret and is required every time you submit a URL to the IndexNow API:

.github/workflows/submit_sitemap_to_index_now.yml
15
          api_key: ${{ secrets.INDEX_NOW_API_KEY }}

If you don't want to use the API key generator from Microsoft Bing, you can create your own API key.

How to Keep Your API Key Secure

IndexNow requires an API key stored on your website, but how do you keep it secret and secure?

For public repositories, you normally can't hide your IndexNow API key and its location – the file is visible in the repository code and the API key is exposed. It's therefore recommended to store your API key as a secret in your repository.

api_key_location#

The location of the API key, e.g. https://example.com/a1b2c3d4.txt. Required every time you submit any URLs or sitemaps to the IndexNow API.

Similar to the api_key, the location of your API key should be kept secret:

.github/workflows/submit_sitemap_to_index_now.yml
16
          api_key_location: https://example.com/${{ secrets.INDEX_NOW_API_KEY }}.txt

endpoint#

Optional. The search engine endpoint, e.g. indexnow, bing, naver, seznam, yandex, yep. If not specified, Bing is used as the default endpoint. Any other value makes the workflow fail before anything is submitted, so a typo doesn't go unnoticed.

.github/workflows/submit_sitemap_to_index_now.yml
17
          endpoint: seznam

Fall Back to Other Endpoints#

Sometimes an endpoint is temporarily unavailable or rejects submissions for a specific site. Instead of a single endpoint, provide a list of endpoints. They are tried in order, and the submission stops at the first endpoint that accepts it:

.github/workflows/submit_sitemap_to_index_now.yml
17
          endpoint: naver, seznam, yep

Alternatively over multiple lines, if that's easier to read:

.github/workflows/submit_sitemap_to_index_now.yml
17
18
19
20
          endpoint: >
            naver
            seznam
            yep

The submission falls back to the next endpoint if the endpoint can't be reached, responds with a server error, 429 Too Many Requests or 403 Forbidden. Other errors, such as 400 Bad Request, indicate a problem with the submission itself, so the workflow fails without trying the remaining endpoints. Learn more about the fallback strategy in the IndexNow for Python documentation.

Warning

It is not recommended to submit the same URLs to multiple endpoints. Once you have successfully submitted to one IndexNow endpoint, the IndexNow service is designed to propagate your URLs to other search engines, so you do not need to submit to multiple times.

A list of endpoints doesn't submit to all of them. It stops at the first endpoint that accepts the submission, and the remaining endpoints are only used as fallback.

urls#

Optional. The URL(s) to be submitted to IndexNow. Can be an individual URL, e.g. https://example.com:

.github/workflows/submit_sitemap_to_index_now.yml
18
          urls: https://example.com

Or multiple URLs as list:

.github/workflows/submit_sitemap_to_index_now.yml
18
          urls: https://example.com/page1 https://example.com/page2

Alternatively over multiple lines, if that's easier to read:

.github/workflows/submit_sitemap_to_index_now.yml
18
19
20
          urls: >
            https://example.com/page1
            https://example.com/page2

sitemap_locations#

Optional. The location of the sitemap(s) from which the URLs will be submitted to IndexNow. Can be an individual sitemap, e.g. https://example.com/sitemap.xml:

.github/workflows/submit_sitemap_to_index_now.yml
19
          sitemap_locations: https://example.com/sitemap.xml

Or multiple sitemaps as list:

.github/workflows/submit_sitemap_to_index_now.yml
19
          sitemap_locations: https://example.com/sitemap1.xml https://example.com/sitemap2.xml

Alternatively over multiple lines, if that's easier to read:

.github/workflows/submit_sitemap_to_index_now.yml
19
20
21
          sitemap_locations: >
            https://example.com/sitemap1.xml
            https://example.com/sitemap2.xml

Nested Sitemaps

Whether you submit one sitemap or multiple, this service will automatically detect any nested sitemaps and include their URLs in the submission.

For example, if you have a sitemap index that links to two other sitemaps, the URLs from all three sitemaps will be included in the submission to the IndexNow API:

sitemap_index.xml
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>https://example.com/sitemap1.xml</loc>
    </sitemap>
    <sitemap>
        <loc>https://example.com/sitemap2.xml</loc>
    </sitemap>
</urlset>

In this case, you only need to submit a single-sitemap with a link to sitemap_index.xml as the location.

Note that only sitemaps on levels 1 and 2 are supported. Nested sitemaps on level 3 and beyond will be ignored.

sitemap_filter#

Optional. Only submit sitemap URLs that contain the filter string, e.g. section1. Optional.

.github/workflows/submit_sitemap_to_index_now.yml
20
          sitemap_filter: section1

Or filter the sitemap URLs for both section1 and section2 using a regular expression:

.github/workflows/submit_sitemap_to_index_now.yml
20
          sitemap_filter: "r'(section1)|(section2)'"

Alternatively, imagine that you want to prevent a whole section from being submitted. This can be achieved using a negative regular expression. This will match any URL that does not include the string /section1/:

.github/workflows/submit_sitemap_to_index_now.yml
20
          sitemap_filter: "r'^((?!/section1/).)*$'"

sitemap_days_ago#

Optional. Only submit sitemap URLs that have been modified recently based on the <lastmod> tag, e.g. 1, 2, or more days ago.

For example, all sitemap URLs that have been modified in the last week days will be submitted:

.github/workflows/submit_sitemap_to_index_now.yml
21
          sitemap_days_ago: 7

Or only submit sitemap URLs that have been modified since yesterday:

.github/workflows/submit_sitemap_to_index_now.yml
21
          sitemap_days_ago: 1

Or only submit sitemap URLs that have been modified today:

.github/workflows/submit_sitemap_to_index_now.yml
21
          sitemap_days_ago: 0

retries#

Optional. Number of times to retry a request on temporary errors, such as dropped connections, timeouts, 429 Too Many Requests or server errors like 503 Service Unavailable. By default, it's set to 0, which means that requests are not retried. Enable retries, so a short glitch at the search engine doesn't make your workflow fail:

.github/workflows/submit_sitemap_to_index_now.yml
22
          retries: 3

Between retries, the wait time increases exponentially (0, 2, 4 seconds, etc.). Other errors, such as 400 Bad Request or 403 Forbidden, aren't retried, as sending the same request again gives the same result.

If you have provided multiple endpoints, each endpoint is retried before the submission falls back to the next one.

Learn more about retries and timeouts in the IndexNow for Python documentation.