A simple static site generator with deployment to S3/Cloudfront.

Overview

Stasis

A simple static site generator with deployment to S3/Cloudfront.

Features

Stasis is a static website generator written in Python, using Pandoc to convert Markdown documents to html rendered with Jinja2 templates, and optionally deploying to Amazon S3 and Cloudfront.

Stasis is designed to mimic the workflow offered by Jekyll and is mainly targeted at personal blogs. The feature set is quite basic, but this also makes the program easy to understand and extend to fit your needs.

  • Conversion of Markdown posts to html, with Pandoc extensions available at your discretion.
  • Workflow similar to Jekyll: init, clean, build, serve, deploy.
  • Easy to use templates with Jinja2.
  • A basic development server for previewing the site locally.
  • Index pages with pagination.
  • Static or "flat" pages, also written in Markdown and rendered to a specified url (eg. about, contact, 404).
  • A sidebar with links, recent posts, and topics.
  • Topic pages.
  • RSS feed generation.
  • Deployment to S3 with dry-run, ignore on server, exclude from upload, and Cloudfront invalidation.
  • Static file pass-through for CSS, Javascript, media, and legacy content.
  • Purely static html output.

For more detail and background, please see my blog post about why I wrote Stasis.

Install

First, install Pandoc following the documentation for your system.

To install the latest distribution of Stasis from PyPI, install using pip. The install will create a console script called stasis, so I recommend doing this within a virtual environment.

pip install stasis-ssg

Alternatively, for the latest source code, clone this repository first and then install the package from a local working directory, for example:

mkdir stasis-devel && cd $_
mkdir .venv
python3 -m venv .venv/stasis
source .venv/stasis/bin/activate

git clone https://github.com/czep/stasis.git .
pip install -e .

Run stasis -v to verify that the install worked.

Use

After installation, create a new working directory in which to develop your site. Make sure this is a new empty directory:

mkdir ~/mysite && cd $_
stasis init

The init command will create a basic starter site in the current directory. The default setup will look like this:

├── _pub                # target location for building the site and staging for deployment
├── drafts              # optional drafts folder
├── pages               # static pages
├── posts               # markdown posts
├── stasis_config.py    # configuration options
├── static              # files to be copied directly to _pub
└── templates           # Jinja2 templates

After initializing the site, the next steps are:

  • Edit stasis_config.py to customize your site's metadata and other configuration options.
  • Edit the templates to get the layout you want.
  • Copy your CSS file to static/css/main.css. Add any additional static files to the static directory. These will be copied to _pub without being processed.
  • Add static pages to the pages directory.
  • Add posts to the posts directory.

These commands will help you build and deploy your site:

stasis build
stasis clean
stasis build --target=prod
stasis serve
stasis deploy --dry-run
CLOUDFRONT_ID=EXXXXXXXXXXXXX stasis deploy

build

Running stasis build alone or with the development target stasis build --target=dev will generate the site with relative links. Internal and tags will begin with /. This makes it easier to navigate through the site when serving it locally. Building with the production target stasis build --target=prod will prepend the site's baseurl defined in stasis_config.py to all links, making them absolute instead of relative. This is likely what you will want to do before deployment to ensure that all of your links point to their respective canonical pages.

To build the site with drafts enabled, run:

stasis build --drafts

clean

At any point if you want to do a fresh rebuild, run stasis clean. This will delete everything in _pub as well as the cached posts in post_store.db.

serve

Start a very simple web server to preview your site. Unlike in Jekyll, there is not an option to serve the site with or without drafts. The server will simply show you whatever has been built in the _pub directory.

deploy

Before trying to deploy, change the AWS_PROFILE and S3_BUCKET config options. I recommend creating a new profile that has S3 Read/Write permission as well as permission to invalidate your Cloudfront distribution. Add this profile to your ~/.aws/credentials.

The first time you try to deploy, please do so with the --dry-run argument to make sure the the results are what you expect. Dry run will connect to your S3 bucket, compare local and remote files, and print an output containing three sections:

  1. New files to upload to S3
  2. Modified files to upload to S3
  3. Old files to delete from S3

Examine the list before running without the dry-run option. In stasis_config.py, there are two pattern lists that can help control what is and is not deployed: IGNORE_ON_SERVER specifies patterns that will not be added, modified, or deleted. Use this for any legacy content that you want to manage manually. EXCLUDE_FROM_UPLOAD specifies patterns that will not be uploaded to S3 from your local filesystem.

By default, stasis will compress most text files before uploading. This can be toggled with the S3_USE_GZIP config option. If True, for all files that meet the gzip criteria, a copy will be created with an extension of ".upload". This is simply a gzipped copy of the original file and is only used during the deployment process. However, you must keep the pattern "*.upload" in EXCLUDE_FROM_UPLOAD to prevent these files from also being uploaded.

When ready to deploy, pass your cloudfront distribution ID as an environment variable:

CLOUDFRONT_ID=EXXXXXXXXXXXXX stasis deploy

After deploying to S3, this will start a root-level wild-card invalidation '/*'. If you do not want stasis to do the invalidation for you, or if you are not using Cloudfront at all, simply run:

stasis deploy

This will deploy to S3 but will not attempt a Cloudfront invalidation.

You might also like...
a static website generator to make beautiful customizable pictures galleries that tell a story
a static website generator to make beautiful customizable pictures galleries that tell a story

Prosopopee Prosopopee. Static site generator for your story. Make beautiful customizable pictures galleries that tell a story using a static website g

A static website generator for people who enjoy the simpler things in life.

A static website generator for people who enjoy the simpler things in life.

The lektor static file content management system
The lektor static file content management system

Lektor Lektor is a static website generator. It builds out an entire project from static files into many individual HTML pages and has a built-in admi

Makes dynamic linked shit "static". Amazing

static.py What does it do? You give it a dynamically linked binary and it will make a directory that has all the dependencies (recursively). It also f

Hobby Project. A Python Library to create and generate static web pages using just python.

PyWeb 🕸️ 🐍 Current Release: 0.1 A Hobby Project 🤓 PyWeb is a small Library to generate customized static web pages using python. Aimed for new deve

A declarative website generator designed for high-quality websites, with a focus on easy maintenance and localization.

Grow Grow is a declarative tool for rapidly building, launching, and maintaining high-quality static HTML. Easy installation Jinja template engine Con

A python-based static site generator for setting up a CV/Resume site
A python-based static site generator for setting up a CV/Resume site

ezcv A python-based static site generator for setting up a CV/Resume site Table of Contents What does ezcv do? Features & Roadmap Why should I use ezc

Django-static-site - A simple content site framework that harnesses the power of Django without the hassle

coltrane A simple content site framework that harnesses the power of Django with

Fully Automated YouTube Channel ▶️with Added Extra Features.

Fully Automated Youtube Channel ▒█▀▀█ █▀▀█ ▀▀█▀▀ ▀▀█▀▀ █░░█ █▀▀▄ █▀▀ █▀▀█ ▒█▀▀▄ █░░█ ░░█░░ ░▒█░░ █░░█ █▀▀▄ █▀▀ █▄▄▀ ▒█▄▄█ ▀▀▀▀ ░░▀░░ ░▒█░░ ░▀▀▀ ▀▀▀░

Scan Site -       Tools For Scanning Any Site and Get Site Information
Scan Site - Tools For Scanning Any Site and Get Site Information

Site Scanner Tools For Scanning Any Site and Get Site Information Example Require - pip install colorama - pip install requests How To Use Download Th

Simple, lightweight, and magic-free static site/blog generator for Python coders

makesite.py Take full control of your static website/blog generation by writing your own simple, lightweight, and magic-free static site generator in

dirmaker is a simple, opinionated static site generator for quickly publishing directory websites.
dirmaker is a simple, opinionated static site generator for quickly publishing directory websites.

dirmaker is a simple, opinionated static site generator for publishing directory websites (eg: Indic.page, env.wiki It takes entries from a YAML file and generates a categorised, paginated directory website.

Official s3cmd repo -- Command line tool for managing Amazon S3 and CloudFront services

S3cmd tool for Amazon Simple Storage Service (S3) Author: Michal Ludvig, [email protected] Project homepage (c) TGRMN Software and contributors S3tools

The deployment framework aims to provide a simple, lightweight, fast integrated, pipelined deployment framework that ensures reliability, high concurrency and scalability of services.

savior是一个能够进行快速集成算法模块并支持高性能部署的轻量开发框架。能够帮助将团队进行快速想法验证(PoC),避免重复的去github上找模型然后复现模型;能够帮助团队将功能进行流程拆解,很方便的提高分布式执行效率;能够有效减少代码冗余,减少不必要负担。

Static site generator that supports Markdown and reST syntax. Powered by Python.

Pelican Pelican is a static site generator, written in Python. Write content in reStructuredText or Markdown using your editor of choice Includes a si

Static site generator that supports Markdown and reST syntax. Powered by Python.

Pelican Pelican is a static site generator, written in Python. Write content in reStructuredText or Markdown using your editor of choice Includes a si

Static site generator for designers. Uses Python and Django templates.

News Cactus 3 is out! We're happy to announce Cactus 3. It brings a set of great new features like asset fingerprinting, an asset pipeline, pretty url

AutoLoader is a plugin for Pelican, a static site generator written in Python.

AutoLoader AutoLoader is a plugin for Pelican, a static site generator written in Python. AutoLoader is designed to autoload the other Pelican plugins

Kaktos is a python static site generator
Kaktos is a python static site generator

Python static site generator κάκτος Kaktos is a python static site generator. The idea is create a simple static site generator for people that don't

Owner
Scott Czepiel
Scott Czepiel
Simple, lightweight, and magic-free static site/blog generator for Python coders

makesite.py Take full control of your static website/blog generation by writing your own simple, lightweight, and magic-free static site generator in

Sunaina Pai 1.7k Jan 1, 2023
dirmaker is a simple, opinionated static site generator for quickly publishing directory websites.

dirmaker is a simple, opinionated static site generator for publishing directory websites (eg: Indic.page, env.wiki It takes entries from a YAML file and generates a categorised, paginated directory website.

Kailash Nadh 40 Nov 20, 2022
Static site generator that supports Markdown and reST syntax. Powered by Python.

Pelican Pelican is a static site generator, written in Python. Write content in reStructuredText or Markdown using your editor of choice Includes a si

Pelican dev team 11.3k Jan 4, 2023
Static site generator for designers. Uses Python and Django templates.

News Cactus 3 is out! We're happy to announce Cactus 3. It brings a set of great new features like asset fingerprinting, an asset pipeline, pretty url

null 3.4k Jan 1, 2023
AutoLoader is a plugin for Pelican, a static site generator written in Python.

AutoLoader AutoLoader is a plugin for Pelican, a static site generator written in Python. AutoLoader is designed to autoload the other Pelican plugins

null 2 Nov 7, 2022
Kaktos is a python static site generator

Python static site generator κάκτος Kaktos is a python static site generator. The idea is create a simple static site generator for people that don't

Paulo Coutinho 4 Sep 21, 2022
barely is a lightweight, but highly extensible static site generator written in pure python.

barely is a lightweight, but highly extensible static site generator. Explore the docs » Quickstart · See available Plugins · Report Bug · Request Fea

null 40 Dec 1, 2022
Simple Static Site Inductor Made in Python

sssimp ?? Simple Static Site Inductor Made in Python How to use Create a folder called input, inside create a folder called content and an empty file

Tina 11 Oct 9, 2022
A static website and blog generator

Nikola, a Static Site and Blog Generator In goes content, out comes a website, ready to deploy. Why Static Websites? Static websites are safer, use fe

Nikola, a static site generator 2.4k Jan 5, 2023
A Python Static Website Generator

Version 0.8.9 Overview Hyde starter kit by merlinrebrovic is a really nice way to get started with hyde. Hyde layout for bootstrap by auzigog is also

Hyde - Static Website Generator 1.6k Jan 1, 2023