This is a very basic Pandoc static site generator.
I've avoided writing CSS beyond some very basic readability improvements/demonstrating that CSS can be added. The goal here is just to populate well-structured HTML documents and a generated JSON feed. View a demo site.
Deeply unattractive out of the box? Yes. Easy to customize? I hope so.
pandoc- Python 3
- Python dependencies listed in
requirements.txt. Install them withmake install.
- Clone this repository.
- Write Pandoc-compatible Markdown files in
posts. These should include YAML frontmatter for generating the index:title: a human-readable title for this post.date: an ISO 8601 date (make date).abstract: a summary you want to appear on the index. This can include valid Pandoc markdown.
- Run
make allto build an HTMl file for each Markdown page and generateindex.html.
make requirements.txt: install dependencies formake_index.py.make hook: configure a git hook to runmake allbefore each commit (so each commit contains an up-to-date static site).
Makefile is the most robust guide, but here's a high-level overview.
-
pandoctransforms each Markdown post inpostsinto a static HTML file ingen. The HTML is structured usingtemplates/post.htmland styled withstyles/shared.css. -
make_index.pyreads the YAML frontmatter of every Markdown post inpostsand transforms this into an intermediate Markdown document of headers and metadata,index.md. -
pandoctransformsindex.mdintoindex.html. Unlike the posts, this index file is structured usingtemplates/index.htmland it's styled with bothstyles/shared.cssandstyles/index.css(with the latter styles overriding the former.
A general rule of thumb: changes to the HTML are predictable; changes to pre-pandoc Markdown are unpredictable. Markdown intermediates (like make_index.py uses for the time being) are antipatterns.
-
Want to change how posts are represented in the index?
Modifymake_index.py. -
Want to add static elements, e.g. a section with "about me" info or social links?
Modifytemplates/index.htmlto only change the index.
Modifytemplates/post.htmlto only change the post pages. -
Want to change how the index is styled?
Modifystyles/index.css. -
Want to change how the whole generated site is styled?
Modifystyles/common.css.
pandoc-blog converts Markdown to HTML with pandoc's fenced_divs extension enabled. You can use this to define a div––complete with HTML attributes––in your markup:
This text is outside of the fenced `div`.
::: {.addendum date="Oct. 12, 2020"}
This text is in a div with class `addendum` and attribute `date="Oct. 12, 2020"`.
:::
This text is outside of the fenced `div`.You can modify styles/common.css to apply styles to those fenced divs and their children:
/* Style addenda. */
div.addendum {
border: 1px solid grey;
padding: 0 1em;
}
/* Include `date` attribute above addenda. */
div.addendum::before {
display: block;
text-align: center;
color: grey;
width: 100%;
margin-top: 1em;
content: "Addendum " attr(data-date);
}-
make_index.pyshould be extended to read a greater variety of pandoc-supported YAML frontmatter and read full-blog metadata defined in some root YAML file. -
Consider rolling table styles and utility classes into this repo.