Generate sitemaps from configuration
Project description
SitemapCfg
Django's sitemap framework is classic Django. It covers all Django functionality. It's class-based. It's configurable and flexible. It can reverse URLs and ping Google. Most of the time it's exactly what you want, and everything you could want. But not all of the time. Perhaps, like me, you use Django in an unusual way. The sitemap framework is not only difficult to use, it will not do some things I want. So I've made this configuration-based alternative. It's crude, but simple.
Why you would not want to use this app
- Can only output URLs from model URL data, not views
- Has no exclude/filter configuration, outputs everything
- No checks for file-size, subfolder renaming etc.
- Creates an index always, despite one sitemap only
- Ignores most of the sitemap spec
- Can only handle one site
Why you would want to use this app
- Search engines also ignore most of the spec
- 5 minuite setup in 'settings' file only
Documentation
Install
PyPi,
pip install sitemap_cfg
Or download the app code to Django.
The module needs no database tables, but need to declare so the registered module can find models etc. Declare in Django settings,
INSTALLED_APPS = [
...
'sitemap_cfg.apps.SitemapCfgConfig',
]
Configuration
Need to declare where the sitemap files will go,
SITEMAP_DIR = PROJECT_DIR / "static"
The domain (usually aiming for cannonical),
SITEMAP_DOMAIN = "https://freefalling.com"
Sitemap index name defaults to 'sitemap_index', but can be renamed,
SITEMAP_INDEX_NAME = 'sitemap_main'
Then declare which models to use, or URLs to add. Keys are the sitemap filename,
SITEMAP = {
# Model names are just the app/model name (not the full path)
# If model is the only data given, tries to use get_absolute_url()
'sitemap_reviews' : [
{'model': 'reviews.Review'},
],
# Can use data from the model to construct URLs, usually a slug
# 'url_path' is the intermediate parh, so allows custom URL path
'sitemap_infopages' : [
{'model': 'infopages.Infopage', 'field' : 'slug', 'url_path': 'info'},
],
# can also declare one-off URLs.
# if preceeded by ''http' these are written as presented...
# if written as stubs get prepended by SITEMAP_DOMAIN
'sitemap_other' : [
{'urls': ['credits', '', 'https://freefalling.com/' ]},
],
# Can have different collections of data in one sitemap
'sitemap_netfeatures' : [
{'model': 'reviews.SongReview'},
{'model': 'datelists.Itineries'},
],
# Can set 'priority' on any dataset
# Value is a string from '0.0' to '1.0'
# (spec defaults to '0.5')
'sitemap_netfeatures' : [
{'urls': ['https://freefalling.com'], 'priority': '1.0'},
{'urls': ['https://freefalling.com/about', 'https://freefalling.com/contact'], 'priority': '0.8'},
],
}
Note that, at the time of writing, Google say they don't use 'priority'.
Generate sitemaps
./manage.py mksitemap
End of...
Said it was simple.
Project details
Release history Release notifications | RSS feed
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
Hashes for sitemap_cfg-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f66f6b2c27488bf5842c428f6cb04d34be46f7787853f1a38272c3b359915a8 |
|
MD5 | d04de3c477bd17c0829f8ac59dcb0281 |
|
BLAKE2b-256 | 648f2048e9287725ee87fd38d7b2eacdef0127266976bb82a268670d0fb42fba |