A simple POSIX shell script that helps me maintain my homepage.
I write all articles on my homepage in Markdown. Then I convert them to HTML.
When I have edited an existing article, I compare the new version with the
old (published) version. Finally, I publish my new/updated article by copying
it to the right (sub)folder of my homepage (which is mounted via sshfs
).
For all these tasks I use homepage
:
homepage convert my-article.md
homepage compare my-article.html
homepage publish my-article.html
The configuration is read from ~/.config/homepage/config
if available
or else from config
in the homepage
script directory.
Set all variables in your copy (or the original otherwise) to your needs.
When you use homepage convert FILE
, the created HTML output is pasted
into an HTML template which contains HTML metadata, a header and a footer,
links a CSS file and possibly JavaScript files.
The path to the HTML template is set in the configuration file (TEMPLATE=
).
Otherwise, homepage
searches for TEMPLATE.html
in
- the current working directory,
- the root directory of the local copy of the homepage (
$LOCAL
), $HOME/.config/homepage/
- in the directory of the
homepage
script.
homepage convert
calls md2html
(→mity/md4c) which needs
to be in your PATH
.
homepage convert
expects Markdown files that start with a comment/header
like this:
[//]: # (
Title: st as an Alacritty replacement
Description: How to configure st coming from Alacritty
Date: 2021-08-01
Update: 2022-12-17
)
Title
: Used as HTML title, Open Graph protocol title andH1
header. The OG title is restricted to 35 characters.Description
: Used as HTML metadata and Open Graph description. The latter is restricted to 65 characters.Date
: Date of creation, inserted as first paragraph (depending on the template). If missing, current (conversion) date is used.Update
: Date of last modification, inserted next to the date of creation (depending on the template). Optional.
Since the default template uses the H1
header for the article title, I use only H2
to H6
in my Markdown files.
When a Markdown file contains a comment like this:
<!-- class="number-table striped-table" -->
… homepage convert
will add these attributes to the following tag in the resulting HTML file.