Generate page headers #36
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: ktyl/ktyl.dev#36
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Page headers are not dynamically generated.
Page preambles are currently generated using a static
inc_html/header.html
file which is the same for every page, meaning every page has the same metadata. Page titles are then awkwardly inserted by injecting templates before and after a bit of text.The entire
<head>
section should be generated per-page to provide the correct keywords and description, removing the need for the#header.html
template. Instead, a Python processing step can be run on input HTML files to generate an appropriate header. The<head>
tag should be inserted directly before<body>
.TOML metadata
Per-page information required can be written directly into the source file using a TOML format, and replaced with a fully generated header with the relevant repeated includes for styles, etc. The Python processor can read this metadata directly from the input file.
This Python function can read a TOML block out of a file.
Metadata should not be included in the output file. We therefore need to match the whole block and substitute it with nothing. This function will return a string containing the contents of the file, minus the metadata block.
Metadata values can then be injected into a template using str.replace(). In the case that no metadata was provided for that page, we should exit with an error exit code. We could provide default metadata, but that would get harder to check as the site scales, so it would be better to fail the build entirely and force metadata to be included.