the end result we are trying to get to is a pages list.

a pages list has a name .. the name of the page to use in liquid templating
and blocks .. blocks also to use in liquid templating.

page mappings
blocks within page mappings

jinja to render the blocks

render.py code


# 1. Load templates from the templates folder
env = Environment(loader=FileSystemLoader('templates'))
template = env.get_template('multi-content.html')

# Loop through pages and render each separately
for page in pages:
    if page['type'] == "python_page":
        html_output = template.render(pages=pages,current_name=page["name"],nav_order=page["nav_order"],title=page["title"], blocks=page["blocks"])
        filename = f"output/{page['name'].replace(' ', '_')}.html"
        with open(filename, "w", encoding="utf-8") as f:
            f.write(html_output)
        print(f"Saved {filename}")


This site uses Just the Docs, a documentation theme for Jekyll.