An open API service indexing awesome lists of open source software.

https://github.com/smncd/galette

Docker powered markdown-to-HTML server, built with Starlette and Uvicorn. Mirror of https://gitlab.com/smncd/galette
https://github.com/smncd/galette

docker jinja2 markdown python starlette static-site static-site-generator uvicorn webapp

Last synced: 2 months ago
JSON representation

Docker powered markdown-to-HTML server, built with Starlette and Uvicorn. Mirror of https://gitlab.com/smncd/galette

Awesome Lists containing this project

README

          

![Galette](./docs/assets/banner.jpg)
=============================

Galette is a Docker powered Markdown-to-HTML server, built with Starlette and Uvicorn.

Why does Galette exist? Mostly for fun, and because I'll maybe need it at some point. Guess we'll find out.

Getting started
---------------

The easiest way to get going is with Docker. You'll need Docker Compose installed.

Create a `compose.yaml` file like so:
```yaml
services:
galette:
image: registry.gitlab.com/smncd/galette
ports:
- 5000:5000
volumes:
- /path/to/your/pages/:/pages
- /path/to/your/assets/:/assets
```

At the path specified in your `compose.yaml` file, create `index.md` (or any other page name, but make sure the name is url friendly):
```markdown

# Hello world

Galettes are very tasty!
```

You can then start the service:
```bash
docker compose up -d
```

Visit `http://localhost:5000` and you will see your markdown, rendered as HTML.

Templates and static files
--------------------------

Galette ships with some default templates, using [Simple.CSS](https://github.com/kevquirk/simple.css), but you will probably want to customize it even further.

To use custom templates and/or static files, edit your `compose.yaml` from above:

```yaml
services:
galette:
image: registry.gitlab.com/smncd/galette
ports:
- 5000:5000
volumes:
- /path/to/your/pages/:/pages
- /path/to/your/assets/:/assets
- /path/to/your/templates/:/templates # <--- templates folder
- /path/to/your/static/:/static # <--- static folder
```

The static folder can be used however you want/need, but the templates folder needs at least two files for Galette to be happy:

* `page.jinja2`: The default page template.
* `404.jinja2`: The 404 page template.

### Different templates

You can have multiple page templates, and choose which one you want your page to use. Simply create a file in your templates folder, `post.html.jinja2` for example, and put your markup in there. To make a page use this template, add the following to the frontmatter:

```yaml
---
# ...
template: post
# ...
---
```

If no template is specified, the default, `page`, will be used.

### Tip!

Templates can have several file extensions. Galette will look for them in the following order:

1. `{name}.html.jinja2`
2. `{name}.html.jinja`
3. `{name}.jinja2`
4. `{name}.jinja`
5. `{name}.html`

As you can tell by the file extensions, Galette uses [Jinja2](https://jinja.palletsprojects.com/en/stable/templates/) for templates.

The frontmatter from your markdown files will be accessible in the templates, along with `html`, which is the body content.

An example template could end up looking like:
```html

{{ title }}


{{ title }}



{{ html }}

```

If we give it this markdown:
```markdown
---
# /path/to/your/pages/pastry.md
title: Flaky pastry
---

We love that stuff!
```

You'd end up with the following rendered page:
```html

:

Flaky pastry


Flaky pastry



We love that stuff!

```

Static files have the base `/static`, so `/path/to/your/static/main.css` would end up being `http://localhost:5000/static/main.css`.

Some examples are available [here](./docs/examples/)

License and Ownership
---------------------
Copyright © 2025 Simon Lagerlöf [contact@smn.codes](mailto:contact@smn.codes)

This project is licensed under the BSD-3-Clause license - see the [LICENSE](./LICENSE) file for details.

Galette's default templates uses [Simple.CSS](https://github.com/kevquirk/simple.css), licensed under the MIT license.