Skip to main content

Write Markdown and Jinja2 templates to create a website

Project description

htmd

htmd allows you to write Markdown and use templates to create a static website. Yes it is another static site generator.

Why another static site generator?

I admit I didn't try them all. I tried several static site generators written in Python, but I found them complicated. Some static site generators I tried created a template website with content on the home page but the index.html file had no content. I think it should be obvious where the content is coming from.

  • I didn't like starting with a lot of folders and files
  • I want all blog posts in the same folder because it is easier to work with. I want the URL structure for each post to include the date (/2015/01/31/post-title), without having to create a folder for each year and month.
  • I didn't want to include all of the templates being used, only overwrite the ones I modified.
  • I wanted it to be obvious where the content was coming from.
  • I want it be obvious how to set a value to use in multiple templates.
  • If you made changes to one of your templates and ran build you wouldn't update existing files unless you deleted your build folder everytime.

I believe the reason there are so many static site generators is people are picky about their workflow and that's okay. This is also a learning experience creating a Python package with a cli.

What is the difference between posts and pages?

Posts are blog posts with dates and authors tracked by feeds. Pages are other webpages on the site, for example the About page.

How do I edit the layout of the site?

Edit the templates/_layout.html file that was created when running htmd start. This a Jinja 2 template that all other pages will use by default. You can add a link to CSS file that you have created in static/. To change other pages you will need to override the page template by creating a file with the same name in the templates/ folder. The complete list of templates can be found here.

Getting Started

$ pip install htmd
Commands:
  start      Create example files to get started.
  verify     Verify posts formatting is correct.
  build      Create static version of the site.
  preview    Serve files to preview site.
  templates  Create any missing templates

Development

Running the development version locally

$ git clone https://github.com/Siecje/htmd.git
$ python3 -m venv venv
$ venv/bin/python -m pip install pip setuptools wheel --upgrade
$ venv/bin/python -m pip install -e htmd/
# You can now make changes inside htmd/ without having to re-install
$ mkdir my_site
$ cd my_site
$ ../venv/bin/htmd start
$ ../venv/bin/htmd build

Running the tests

$ venv/bin/python -m pip install pytest
$ venv/bin/python -m pytest .

Running the tests with coverage.py

$ venv/bin/python -m pip install coverage
$ venv/bin/coverage run -m pytest .
$ venv/bin/coverage html --omit='/private/*'
$ open htmlcov/index.html

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

htmd-2.0.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

htmd-2.0.0-py2.py3-none-any.whl (19.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file htmd-2.0.0.tar.gz.

File metadata

  • Download URL: htmd-2.0.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1

File hashes

Hashes for htmd-2.0.0.tar.gz
Algorithm Hash digest
SHA256 7a537f882dc50feece44e99e538ba73d44a818ee21c8055afafe0ec21d67379f
MD5 3daab5c3713be70c3cce1d36ea20a7c4
BLAKE2b-256 e32b2dd9d5a45e3cfa5f6ca126ebdb8676da37faf0a8210141c8f89f4010a23c

See more details on using hashes here.

File details

Details for the file htmd-2.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: htmd-2.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1

File hashes

Hashes for htmd-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e5aff690dc3b7c49437a4fc07a3c1071c583e31c4750017a5c03318268d3eb03
MD5 0ba22735f39aa092b2429db84a54734f
BLAKE2b-256 3f172556daa08dc0c20649180088a9ebd979438f188db796c645b34cc244cd21

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