Coder Social home page Coder Social logo

htmd's Introduction

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. It should be obvious where to find the content.

  • I don'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 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 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.

How do drafts work?

A post will be a draft if draft: true is set in the metadata and will not appear in the build folder. If draft: build is 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 is draft: build|f47d4d98-9d66-448a-9e08-7b5c2032e558 then the post will served at /draft/f47d4d98-9d66-448a-9e08-7b5c2032e558/index.html.

To view the site as if all drafts were published run htmd preview --drafts.

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 --upgrade
$ venv/bin/python -m pip install -e htmd/[dev]
# You can now make changes inside htmd/ without having to re-install
$ mkdir my_site
$ cd my_site
$ ../venv/bin/htmd start
# You can also create a symlink to htmd
# somewhere on your $PATH and just use `htmd start`
$ ../venv/bin/htmd build

Running mypy

$ venv/bin/python -m mypy .

Running ruff

$ venv/bin/python -m ruff check --exclude typehints

Running the tests

$ git clone https://github.com/Siecje/htmd.git
$ cd htmd
$ python3 -m venv venv
$ venv/bin/python -m pip install pip setuptools --upgrade
$ venv/bin/python -m pip install -e .[dev]
$ venv/bin/python -m pytest .

Running the tests with coverage.py

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

htmd's People

Contributors

siecje avatar

Stargazers

Shoubhit Dash avatar Russ avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

srmcgann

htmd's Issues

Sitemap

Create a sitemap when building.

Remove tool.ruff.lint.per-file-ignores for test files

ruff doesn't see utils.py as a local import in test_build.py and test_verify.py

htmd/pyproject.toml

Lines 69 to 75 in 79c11f3

[tool.ruff.lint.per-file-ignores]
"tests/test_app.py" = ["ARG001"]
"tests/test_build.py" = ["I001"]
"tests/test_drafts.py" = ["ARG001", "I001"]
"tests/test_post_dates.py" = ["I001"]
"tests/test_preview.py" = ["I001"]
"tests/test_verify.py" = ["I001"]

Generate multiple languages

Be able to create the site in multiple languages and have build/en/, build/fr/ etc.

Provide an example nginx config to show how to map to the correct version of the site.

Improve packaging

Currently zip_safe=False, this is because the example_site/ files are included in the package to be installed. They end up in the install directory.

Why can't they be in the zipped wheel?

Could use strings for them and write them to a new file instead of copying.

Pagination

Pages that use the _list.html template do not have pagination.

Register all posts and pages with Frozen-Flask

If the site no longer links to a post or page it will not be built and won't be in the build directory.

Provide a way register routes with Frozen-Flask in case links in templates are changed.

Draft Posts

Be able to set a post as a draft, ensure draft posts do not appear in lists.

Can build with a draft and deploy and link to the draft and get feedback before publishing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.