A presentation at CLEpy in in Cleveland, OH, USA by Zach Passen
Static Sites In Python Kat Passen 1
Before we begin • Taxonomy - classification scheme • Tag - metadata used to classify content • SSG - static site generator • CMS - content management system 2
“what is a static site” 3
“what is a static site” => “what is JAMstack” 4
JAMstack • JavaScript • APIs • Markup 5
🤔 6
What is not JAMstack • Traditional server setup (Django) • CMS-based site • Single Page Application 7
Why JAMstack • Pages generated at deploy time, not during request • All files (including HTML!) can live on CDN • Can use a CMS alongside a JAMstack site: consolidate your stacks • All server-side processes are micro services 8
What is a static site • HTML page with prepopulated content • https://www.staticgen.com/ 9
In this talk: • Lektor • Statik • Pelican • Not things like Sphinx 10
Lektor https://www.getlektor.com/ 11
Lektor - Intro • Partway between SSG and CMS • Aimed more towards CMS-style content, but without the CMS server • WYSIWYG editing with HTML output 12
Lektor - Setup $ curl -sf https://www.getlektor.com/ install.sh | sh 13
🤔😬😩 14
/usr/bin/ruby -e “$(curl -fsSL https:// raw.githubusercontent.com/Homebrew/ install/master/install)” 15
$ pip install pelican $ brew install hugo $ gem install bundler jekyll $ npm install —save-dev @11ty/eleventy … $ curl -sf https://www.getlektor.com/ install.sh | sh 16
Statik https://getstatik.com/ 17
Statik - Intro • Non-blog oriented SSG • “what if Hugo but custom data models” (SQLAlchemy) • Jinja2 templates 18
Statik - Setup $ python3 -m venv path/to/stuff/; source venv/bin/activate $ statik —quickstart (make some views) $ statik —watch 19
Statik - Detail • Quickstart just kind of leaves you hanging • Models and views are defined as YAML, data is defined as either YAML or Markdown • In your data, you can refer to model instances by primary key to autofill info • Dynamic variables in views are just database queries • Themes are separate: https://github.com/thanethomson/ statik-themes 20
Statik - Detail 21
Statik - Detail 22
Statik - Results 23
Pelican https://blog.getpelican.com/ 24
Pelican - Intro • Extremely blog-oriented - category taxonomy, chronological content • “Pages” - non-content pages (about, contact) • Content is reStructuredText or Markdown 25
Pelican - Intro • i18n support (thru plugins) • Jinja2 templates • Integrates with various third-party services (thru plugins) 26
Pelican - Demo 27