Search code examples
templatesmarkdowngithub-flavored-markdown

Anyway to have a Markdown template?


I have a knowledge content I need to store in a github repo. The content is around 40 files (right now in 40 docx). They're all pretty much a one-page file. They have a common structure:

Problem

Some blurb

Options

some blurb

Recommendation

Some blurb

If I write down 40 md files (copy/paste the structure and fill in blurbs), I risk dealing later with the issue of structure needing a slight change - for example Renaming "Recommendation" to "Solution", or some other formatting details. I'd have to touch 40 files just for formatting.

There must be a better way.

For example, is there a way to define the template of the md file in one place, and then create the 40 md files that hold the content but in a way that is not necessarily formatted. Then have something that renders those files using the template?


Solution

  • I risk dealing later with the issue of structure needing a slight change - for example Renaming "Recommendation" to "Solution", or some other formatting details. I'd have to touch 40 files just for formatting.

    You will always need to pick a certain structure for your data.

    The idea of templating is to separate presentation from data. Any templating solution will need to read its data from some data format (e.g. JSON) and there you will have to define your key-names as well. Whether you have:

    1. a JSON field "recommendation":,
    2. a markdown heading ## Recommendation, or
    3. a HTML heading <h2>Recommendation</h2>

    It doesn't matter. In all three formats you need to choose the field-name (recommendation in this case) and define a structure (even if you don't enforce it with a schema or validator, the structure is still there for the data to be useful). And in all three cases you can later write a script to automatically change the name of the field or heading.

    Thus I would argue you indeed don't gain anything from going beyond the markdown file you already have.