Skip to main content

A stupid, simple, static site generator

Project description

This repo is a stupid, simple, static site generator. It is very opinionated, but you can easily create static sites with jinja templates and json files. This basically cuts the framework out of rendering.

Getting Started

Install

To install from PyPi :

pip3 install sg1

Setup

sg1 start projectname

This creates 3 folders in a directory projectname:

  1. templates: These are the jinja2 templates that will be rendered.

  2. content: JSON files that specify the key value pairs used to render the templates.

  3. html: Output directory of the rendering. This is where your beautifully* rendered html files are generated.

*Beauty not guaranteed.

Templates

See the jinja2 documentation

Content

Example:

# index.json

 {
     "template": "index.html",
     "title": "I'm a title"
     "p": "I'm a paragraph."
     "extras": [
       "about/about.json",
       "posts"
     ]
     ...
}

The only required field is template which is the relative path from the templates folder.

The rest is whatever you want, just make sure the variables are in the template ({{ content.variable }}).

Simple URLs

sg1 urls projectname creates a urls folder in projectname with a urls.json file containing all the project urls for ease of use in the templates.

Example:

Let’s say you have a content file posts/post.json. The above command will add relative reference in the urls.json file like:

{
  ...,
  "posts__post": "/posts/post.html",
  ...
}

You can then create a link in the template with <a href="{{ urls.posts__post }}">Post</a>.

HTML

To generate the HTML files, run sg1 render projectname.

To Do

  • ☒ Add extras field to context files that automagically includes context of a specified subfolder (to easily use context from example_post.json to render the image and title in index.html for example).

  • ☐ Pagination of extra

  • ☐ Refactor and general cleanup

  • ☐ Update paths for Windows

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

sg1-0.1.4.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

sg1-0.1.4-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file sg1-0.1.4.tar.gz.

File metadata

  • Download URL: sg1-0.1.4.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for sg1-0.1.4.tar.gz
Algorithm Hash digest
SHA256 57fb10516d3484afc30deaffa7b564a0baea546bf017d126e1a7a4b5a0b61bfa
MD5 66a286c667f326cef49351d8d69c4607
BLAKE2b-256 22ce4a59c78e5928e1a6b0c337209a292b7c436be6a94863f49952fd134fb258

See more details on using hashes here.

File details

Details for the file sg1-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: sg1-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for sg1-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 34f293e480c76c4d3b9bd9ccd805b9f8f68c36c5e06a3d7f7a992af8d213c26a
MD5 2e017b6a40cfc36d2ca10953ee7de530
BLAKE2b-256 c2f364da73fcfa1c6dfd5cae383a293d42c172ea7d33ff00c819f30b2a794750

See more details on using hashes here.

Supported by

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