Skip to main content

sitemapr is a library that generates sitemaps for SPA websites with declaritve configuration in Python.

Project description

sitemapr

sitemapr is a Python library designed to generate and save sitemaps for websites. It allows for the creation of detailed sitemaps with customizable parameters, making it easier for search engines to crawl and index web pages efficiently.

Features

  • Generate sitemaps with dynamic URL parameters.
  • Split large sitemaps into chunks to comply with sitemap index specifications.
  • Customizable base URLs for sitemaps and websites.

Installation

SiteMapr can be easily installed using pip. Ensure you have pip installed and run the following command:

pip install sitemapr

This command will download and install SiteMapr along with its dependencies.

Quick Start

Here's how to quickly generate a sitemap for your website using SiteMapr:

  1. Define Your Pages: First, define the pages you want to include in your sitemap, including any dynamic path or query parameters.

  2. Create a SiteMapr Instance: Initialize SiteMapr with your website's base URL and the pages you've defined.

  3. Save Your Sitemap: Choose a directory and save your sitemap, specifying chunk sizes if needed.

Example

from sitemapr import Page, Param, SiteMapr

# Define the pages of your site
pages = [
    Page(
        path="",
        query_params=[
            Param(name="page", values=["home", "about", "contact"]),
            Param(name="sort", values=["asc", "desc"]),
        ],
        priority="1.0",
    ),
    Page(
        path="/blog",
        query_params=[
            Param(name="page", values=["1", "2", "3"]),
            Param(name="sort", values=["asc", "desc"]),
        ],
        # For lastmod, priority, and changefreq field, you can use callback function for more precise control
        lastmod=lambda loc, path_params, query_params: "2024-05-07T00:00:00+00"
    ),
    Page(
        path="/blog/{id}",
        path_params=[Param(name="id", values=["1", "2", "3"])],
    ),
]

# Initialize SiteMapr with your website's base URL and the defined pages
sitemapr = SiteMapr(base_url="https://example.com", pages=pages)

# Save the sitemap to the specified directory
sitemapr.save("/path/to/your/sitemap/directory")

License

sitemapr is released under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sitemapr-0.3.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sitemapr-0.3.4-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file sitemapr-0.3.4.tar.gz.

File metadata

  • Download URL: sitemapr-0.3.4.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/2.3.4 CPython/3.10.20 Linux/6.17.0-1010-azure

File hashes

Hashes for sitemapr-0.3.4.tar.gz
Algorithm Hash digest
SHA256 eca925bfd841220bad24a1aad884b0cae484eed13c86f5fc8676ae154692dab0
MD5 3cae95d9e41531e3dc1c18db5490f688
BLAKE2b-256 3c43231b6c8672c1ff4696bad4059617e261cb551082f2c382503f6eb7924313

See more details on using hashes here.

File details

Details for the file sitemapr-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: sitemapr-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/2.3.4 CPython/3.10.20 Linux/6.17.0-1010-azure

File hashes

Hashes for sitemapr-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8bd5f2e08da8d45ff1228f53965e033b902a1bf61bd7deab97c030ec4144ebf2
MD5 90a3405ddb611d5c1c801415b57acea8
BLAKE2b-256 d927437a1a3486bbfc1dae69ec75bd75a539c51a0f3726b1468e66ec28f85140

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page