django-distill

Static site generator for Django

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 installed django-distill into your Django project you just wrap the URLs you want to generate static pages for by replacing Django's django.urls.path() with django_distill.distill_path():

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.

 Install

Alternatively, you can download the release from PyPI as a Python package

The latest release of django-distill is 3.2.4 published on the 25th of May 2024

View historical releases

 Did you know

This website is powered by Django, uses django-distill and is automatically deployed as a static site to Cloudflare pages! This site is open source and you can view it on GitHub.

 Install

For the step by step guide on how to install django-distill into your Django project, read the installation documentation.

 Integrate

Installed django-distill into your Django project? You can start using the full set of static site generation features, read the integration documentation.

 Deploy

Once you've wrapped your URLs with django-distill you can deploy your static site! Read the deployment documentation.

 417 Stargazers