Get started

Using with nanodjango

See How-tos for a full nanodjango example.

  1. Install nanodjango along with its dependencies for static site generation, including django-nanopages and django-distill:

    pip install nanodjango[static]
    
  2. In your nanodjango script, register your directory of pages at a URL, at the end of your script:

    app.pages(url="", path="pages/")
    
  3. Put your markdown, HTML, or Django template files under the path - in this case, a dir next to your script called pages.

  4. Optional: build to a static site with django-distill:

    nanodjango manage myscript.py distill-local static_site/
    

    See Static site generation for more details about static site generation.

Using with full Django

  1. Install:

    pip install django-nanopages
    
  2. Add it to your INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        ...
        "django_nanopages",
    ]
    
  3. In your urls.py, register your directory of pages at a URL:

    from django_nanopages import Pages
    
    urlpatterns = [
        ...
        path("", include(Pages("pages/"))),
    ]
    

    ```

  4. Put your markdown, HTML, or Django template files under the path - in this case, a dir called pages.

  5. Optional: build to a static site with django-distill:

    ./manage.py distill-local static_site/
    

    See Static site generation for more details about static site generation.

Automatic browser reloading

django-nanopages integrates with [django-browser-reload](https://github.com/adamchainz/django-browser-reload) for automatic browser reloading when you make changes to files within a page directory.

Follow the installation instructions for [django-browser-reload](https://github.com/adamchainz/django-browser-reload), and your page directories will be automatically registered when it is available.