django-distill is an open source, MIT licenced static site generator library for the Django web development framework and is designed to integrate into existing Django projects to allow some, or all of the content in the site to be written out as static pages. Integration is simple and the level of static site generation is up to the project. django-distill integrates with Django, rather than requiring projects to be written for django-distill.
django-distill can be used to build simple static pages, blogs with irregularly updated content or full complex JAM-stack websites with dynamic APIs. Your sites can retain full, modern site features such as database backed content, the full power of the Django CMS and admin as well as optional add-on features like SASS/LESS CSS compilation all while retaining full static site generation.
Once django-distill has been integrated to your Django project you can export a static version of your project to a local directory, use a simple management command to automatically publish your site to a CDN bucket like S3, Google Cloud Files or Azure Blob Storage or even integrate your site to be automatically built and deployed on repository push to a static site hosting service like Netlify, Cloudflare Pages, GitHub pages and more.
How it works
Once you have
django-distill into your Django project you just
wrap the URLs you want to generate static pages for by replacing Django's
from django_distill import distill_path from app.views import page_view urlpatterns = [ # Wrap your URL with distill_path() instead of path() distill_path('page.html', page_view, name='page'), ]
And you're done! You can now generate
page.html as a static page with the
distill-local Django command:
$ python manage.py distill-local /path/to/output/directory
There's support for pages with parameters using a URL generator, generating a subset of files from models, renaming files, publishing to CDNs and much more is detailed in the integration and deployment documentation.
The latest release of django-distill is 3.1.3 published on the 11th of April 2023