Skip to content

Change Frequency Filter Options#

Example#

Let's imagine a basic sitemap with three URLs, each with different change frequencies:

sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>https://example.com</loc>
        <lastmod>2025-01-01</lastmod>
        <changefreq>always</changefreq>
        <priority>1.0</priority>
    </url>
    <url>
        <loc>https://example.com/page1</loc>
        <lastmod>2025-02-01</lastmod>
        <changefreq>hourly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://example.com/page2</loc>
        <lastmod>2025-03-01</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
    </url>
</urlset>

With ChangeFrequency.DAILY in the SitemapFilter we can target any URLs that have a change frequency of daily. Effectively, this will submit the URL https://example.com/page2 to IndexNow because only it has that change frequency:

Python
from index_now import submit_sitemap_to_index_now, IndexNowAuthentication, SitemapFilter, ChangeFrequency

authentication = IndexNowAuthentication(
    host="example.com",
    api_key="a1b2c3d4",
    api_key_location="https://example.com/a1b2c3d4.txt",
)

filter = SitemapFilter(change_frequency=ChangeFrequency.DAILY)

submit_sitemap_to_index_now(
    authentication, "https://example.com/sitemap.xml", filter)

Instead of the predefined ChangeFrequency enumerations, you can also use basic string input:

filter = SitemapFilter(change_frequency="daily")

Documentation#

ChangeFrequency#

The change frequency of a sitemap URL, e.g. <changefreq>monthly</changefreq>, and is used to indicate to a crawler how often the resource is expected to change. Find more inforation at www.sitemaps.org.

Attributes:

Name Type Description
ChangeFrequency.ALWAYS Enum

The resource is always changing.

ChangeFrequency.HOURLY Enum

The resource changes every hour.

ChangeFrequency.DAILY Enum

The resource changes every day.

ChangeFrequency.WEEKLY Enum

The resource changes every week.

ChangeFrequency.MONTHLY Enum

The resource changes every month.

ChangeFrequency.YEARLY Enum

The resource changes every year.

ChangeFrequency.NEVER Enum

The resource never changes.

Example

Get all URLs with a change frequency set to daily:

Python
1
2
3
from index_now import SitemapFilter, ChangeFrequency

filter = SitemapFilter(change_frequency=ChangeFrequency.DAILY)

Instead of the predefined ChangeFrequency enumerations, you can also use basic string input:

filter = SitemapFilter(change_frequency="daily")