Configuration

The Gauguin configuration is written using the yaml format inside the gauguin.yaml file. It must be placed in the root of your Gauguin project.

gauguin.yaml
version: 0.0.1

# Hooks are optional
hooks:
  # Calls this hook before sending the image
  beforeResponse:
    url: https://someserver.com/before
    headers:
      - CustomHeader: customvalue
  # Calls this hook after sending the image
  afterResponse:
    url: https://someserver.com/after
    headers:
      - CustomHeader: customvalue
routes:
  - path: /articles/opengraph
    params:
      - title
      - author
      - image
    size: 1200x630
    template: ./templates/articles/opengraph.tmpl
    cache-control: max-age=2592000, stale-while-revalidate=86400
  - path: /users/opengraph
    params:
      - title
      - first_name
      - last_name
    size: 1200x630
    template: ./templates/users/instagram.tmpl
    cache-control: max-age=2592000, stale-while-revalidate=86400

Given that configuration, we're telling Gauguin that we want the following routes:

  • /articles/opengraph

  • /users/opengraph

for each route, we want to specify the query string parameters that will define the dynamic content of our og:image

That means that if we have a blog and we want to generate a new opengraph image for our blog, we just need to call the following url specifying the previously declared querystring parameters:

Generate New Article og:image

GET http://localhost:8080/articles/opengraph?image=&title=&author=

Query Parameters

<image/jpg>

For each route, we also want to specify the size of the image that we want to generate using the following format: WIDTHxHEIGHT

Last but not least, we tell the template that we want to render on that specific route.

Last updated