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:
-
Define Your Pages: First, define the pages you want to include in your sitemap, including any dynamic path or query parameters.
-
Create a SiteMapr Instance: Initialize SiteMapr with your website's base URL and the pages you've defined.
-
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
Built Distribution
File details
Details for the file sitemapr-0.3.1.tar.gz
.
File metadata
- Download URL: sitemapr-0.3.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36785598b17654b601a8ad33181137404cd8099ef5b868f6050030575b6f9a1c |
|
MD5 | 2cc396d8e7b96f8dc7bd5e5085737a59 |
|
BLAKE2b-256 | 9caef9ba811888a1ddf8d1cac619a881461bea04ab1906ee06c0a1b08f57476d |
File details
Details for the file sitemapr-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: sitemapr-0.3.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb1243f54dc97e9d4ff7151a3d122530d58ba66901ff4d7306e8c65e5e19e30e |
|
MD5 | e8a74d776a478b8beda7b1938757b734 |
|
BLAKE2b-256 | b8ca502c318a2a0dafbb2ea41c344423e82be5583537cb925b1e3d5e4724509e |