Skip to main content

A simple static site generation library

Project description

Ryland

A simple static site generation library

Current Features

  • Jinja2 templates with a basic markdown filter and a function to pull data directly from JSON files
  • copying static files and directory trees (for stylesheets, scripts, fonts, images)
  • cache-busting with hashes

History

I've generally found most static site generation libraries to either be far too complex for my needs or be too restricted to just blogs so, over the years, I've generated many static sites with lightweight, bespoke Python code and hosted them on GitHub pages. However, I've ended up repeating myself a lot so I'm now cleaning it all up and generalizing my prior work as this library.

Changelog

  • 0.1.0 initial release
  • 0.2.0 added the data function with support for JSON

Example Usage

pip install ryland (or equivalent).

The write a build script of the following form:

from ryland import Ryland

ROOT_DIR = Path(__file__).parent.parent
DIST_DIR = ROOT_DIR / "dist"
PANTRY_DIR = ROOT_DIR / "pantry"
TEMPLATE_DIR = ROOT_DIR / "templates"

ryland = Ryland(dist_dir=DIST_DIR, template_dir=TEMPLATE_DIR)

ryland.clear_dist()
ryland.copy_to_dist(PANTRY_DIR / "style.css")
ryland.calc_hash("style.css")

ryland.render_template("404.html", "404.html")
ryland.render_template("about_us.html", "about-us/index.html")

# construct context variables

ryland.render_template("homepage.html", "index.html", {
    # context variables
})

Cache-Busting Hashes

The calc_hash makes it possible to do

<link rel="stylesheet" href="/style.css?{{ HASHES['style.css'] }}">

in the templates.

Markdown Filter

To render a markdown context variable:

{{ content | markdown }}

Data Function

To pull data directly from a JSON file in a template:

<div>
  <h2>Latest News</h2>

  {% for news_item in data("news_list.json")[:3] %}
    <div>
      <div class="news-dateline">{{ news_item.dateline }}</div>
      <p>{{ news_item.content }}</p>
    </div>
  {% endfor %}
</div>

Sites Currently Using Ryland

Roadmap

  • move over other sites to use Ryland
  • incorporate more common elements that emerge
  • add support for YAML data loading in templates
  • produce a Ryland-generated website for Ryland
  • document how to automatically build with GitHub actions
  • write up a cookbook
  • add a command-line tool for starting a Ryland-based site

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ryland-0.2.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ryland-0.2.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file ryland-0.2.0.tar.gz.

File metadata

  • Download URL: ryland-0.2.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for ryland-0.2.0.tar.gz
Algorithm Hash digest
SHA256 69f6ef18c64c98a6e18c84ab68848d2683655b33fb93bd62d7ad63ecc2587c6f
MD5 044b02e250c6e156dd27033b1b31c563
BLAKE2b-256 22856b89749d8866da3e8efa71795298709edf1fd82dccc70f94c6faf5358342

See more details on using hashes here.

File details

Details for the file ryland-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ryland-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for ryland-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8c07286891b8aced925d3d6d41f42a6ad682ca38aa59b231d76d26160e201bb
MD5 a71a082eb53a891b5daacfffab8d7966
BLAKE2b-256 651a36ca2cb8e607eba1a12f26194422401148e10651b6dd67d68e19572f221a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page