Flask Sitemapper
Flask Sitemapper is a Python 3 package that generates XML sitemaps for Flask applications. This allows you to create fully functional sitemaps and sitemap indexes for your Flask projects with minimal code.
You can install the latest version of Flask Sitemapper with pip:
pip install flask-sitemapper
For documentation (including for contributors), see the wiki.
Features
- Easily generate and serve XML sitemaps and sitemap indexes for your Flask apps
- Include URLs in your sitemaps by adding a decorator to their route/view functions
- Serve your sitemap on any URL you choose
- Include lastmod, changefreq, and priority information in your sitemaps
- Specify whether to use HTTP or HTTPS for the URLs in your sitemaps
- Compress your sitemaps using GZIP
- Create multiple sitemaps and sitemap indexes for the same app
- Supports apps using Flask blueprints
- Supports apps serving multiple domains
- Supports dynamic routes
- Works with many different app structures
Sitemaps
Sitemaps are an easy way for webmasters to inform search engines about pages on their sites that are available for crawling. In its simplest form, a Sitemap is an XML file that lists URLs for a site along with additional metadata about each URL (when it was last updated, how often it usually changes, and how important it is, relative to other URLs in the site) so that search engines can more intelligently crawl the site. — sitemaps.org
For more information about sitemaps and the sitemap protocol, visit sitemaps.org
Basic Code Example
import flask
from flask_sitemapper import Sitemapper
sitemapper = Sitemapper()
app = flask.Flask(__name__)
sitemapper.init_app(app)
@sitemapper.include(lastmod="2022-02-08")
@app.route("/")
def home():
return flask.render_template("home.html")
@sitemapper.include(lastmod="2022-03-19")
@app.route("/about")
def about():
return flask.render_template("about.html")
@app.route("/sitemap.xml")
def sitemap():
return sitemapper.generate()
app.run()
With the above code running on localhost, http://localhost/sitemap.xml will serve the following XML sitemap:
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://localhost/</loc>
<lastmod>2022-02-08</lastmod>
</url>
<url>
<loc>https://localhost/about</loc>
<lastmod>2022-03-19</lastmod>
</url>
</urlset>
Release files for flask-sitemapper 1.8.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask_sitemapper-1.8.2.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_sitemapper-1.8.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.5 kB
Release files / flask_sitemapper-1.8.2.tar.gz
| Download URL | flask_sitemapper-1.8.2.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a381ca1e1cd71867c7e7819bacd4bab84bc4fa6074ef9b7ce879fe0d816e942
|
|
BLAKE2b-256 checksum How to use checksums |
5df3d66e518dc9435d4375e526733b56fdef86853e1d482d05f73dda2d5fea9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / flask_sitemapper-1.8.2-py3-none-any.whl
| Download URL | flask_sitemapper-1.8.2-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e93fececd462a2f7abf45fc1a5932d7a30f1c4011e005c42d31b8f74e6230723
|
|
BLAKE2b-256 checksum How to use checksums |
d374a460024e12181db382a832cae9620ed9a85418176a92ff3d39563b4a5274
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|