PaPy – A Python static site generator

2 hours ago 1

Using Python3:

  1. pip install markdown
  2. Copy contents of /pa-py to local directory.
  3. Drop markdown files into /post (see front matter in examples)
  4. Generate with python3 pa.py.
  5. Output is in directory /public, complete with RSS and Sitemap.

/theme files can be tweaked to preference.

Features

PaPy can do what most other static site generators can do. View example blog

  • Converts Markdown files to HTML from folder /post with support for fenced code blocks, tables, footnotes and smart quotes
    • Output URLS are clean; i.e. /post/slug versus /post/slug.html
  • Front Matter Parsing: Extracts metadata from YAML-style front matter
  • Template system: Uses HTML template parts (archive.html, footer.html, header.html, head.html, main.html, page.html, single.html, tags.html) from theme directory
  • Pagination with reverse chronological sorting (newest first)
  • RSS feed and Sitemap generation
  • Static asset handling:
    • Contents of root directory are copied to /public
    • If sub-directories contain markdown files, they too are converted to HTML
    • /static directory for static assets like css and scripts are pushed through
  • SEO-ready: Can output Open Graph, Twitter card meta and JSON-LD Microdata (optional)
  • Tags:
    • Outputs tags from comma-separated front matter: tags: tag1, tag2
    • Outputs tags from on-page hashtag trigger in markdown body {{ hashtag:example }}
    • Front matter tags only are shown at the bottom of the content/blog post
    • All tags (front matter and on-page hashtag trigger) have /tags pages generated and indexed.
    • Tags support for mixed case hashtags
  • Date formatting: Displayed dates can be formatted to preference in themes via Python's strftime() method.

Themes

Some example themes are included:

basic: A basic theme with all posts displayed as a list on the main index page (newest first).
cards: Same as basic, with all main index posts laid out as "cards" or "blocks (in <div> instead of <ul>).
long: Same as basic, with all main index posts appearing in "long" format on the front page, i.e., the full body of each post is shown.

The layouts can be remixed to taste - see the example themes for how to do this.

Read Entire Article