Package: htmd
htmdhtmd 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 themall.
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.
It should be obvious where to find the content.I don't like starting with a lot of folders and filesI 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 don't want to include all of the templates being used, only overwrite the ones I modified.I want it to be obvious where to find the content.I want it to 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 great way to stay up to date with Packaging in Python.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 thetemplates/_layout.htmlfile that was created when runninghtmd start.
This aJinja 2template that all other pages will use by default.
You can add a link to CSS file that you have created instatic/.
To change other pages you will need to override the page template by creating a file with the same name in thetemplates/folder.
The complete list of templates can be foundhere.How do drafts work?A post will be a draft ifdraft: trueis set in the metadata and will not appear in the build folder.
Ifdraft: buildis set then the post page will be in the build but the post will not appear in any list pages. When a draft is built the metadata value will contain a UUID of where the post is available.For example, if the draft metadata isdraft: build|f47d4d98-9d66-448a-9e08-7b5c2032e558then the post will served at/draft/f47d4d98-9d66-448a-9e08-7b5c2032e558/index.html.To view the site as if all drafts were published runhtmd preview --drafts.Getting Started$pipinstallhtmdCommands:startCreateexamplefilestogetstarted.verifyVerifypostsformattingiscorrect.buildCreatestaticversionofthesite.previewServefilestopreviewsite.templatesCreateanymissingtemplatesDevelopmentRunning the development version locally$gitclonehttps://github.com/Siecje/htmd.git
$python3-mvenvvenv
$venv/bin/python-mpipinstallpipsetuptoolswheel--upgrade
$venv/bin/python-mpipinstall-ehtmd/# You can now make changes inside htmd/ without having to re-install$mkdirmy_site
$cdmy_site
$../venv/bin/htmdstart# You can also create a symlink to htmd# somewhere on your $PATH and just use `htmd start`$../venv/bin/htmdbuildRunning mypy$venv/bin/python-mpipinstallmypytypes-Pygmentstypes-beautifulsoup4
$venv/bin/python-mmypy.Running ruff$venv/bin/python-mpipinstallruff
$venv/bin/python-mruffcheck--excludetypehintsRunning the tests$gitclonehttps://github.com/Siecje/htmd.git
$cdhtmd
$python3-mvenvvenv
$venv/bin/python-mpipinstallpipsetuptoolswheel--upgrade
$venv/bin/python-mpipinstall-e.
$venv/bin/python-mpipinstallpytest
$venv/bin/python-mpytest.Running the tests with coverage.py$venv/bin/python-mpipinstallcoverage
$venv/bin/coveragerun--branch-mpytest.
$venv/bin/coveragehtml--omit='/private/*'$openhtmlcov/index.html