Variables can be set on specific pages, or across the entire site.

Site variables

Site variables are often used to change output for development, staging, and production environments. The best place to put these is in combine.yml.

Hard-coding variables in combine.yml

# combine.yml
  str_example: My site
  int_example: 1
  list_example: ["a", "b", "c"]
    # Dict values need to be nested under the "default" key
      key: val

Loading environment variables

You can leverage environment variables keep settings out of your repo or get build environment details from your hosting provider.

# combine.yml
    default: ""
    from_env: URL  # a Netlify variable

If you want the environment variable to be "required", then simply remove the default field.

# combine.yml

Combine will throw an error if you use an "undefined" variable (which can help catch deployment misconfigurations if you forget to set the env variables).

<!-- (HTML) -->
    ...{{ google_tag_manager_id }}

In some scenarios, a missing environment variable is ok and you can write a special if statement to check that case. Be careful when you do this though — you lose your safety net if the env variable is accidentally removed.

<!-- base.template.html -->
{% if google_tag_manager_id is defined %}
    ...{{ google_tag_manager_id }}
{% endif %}

Loading files

Variables can be loaded from JSON, YAML, or text files using the from_file setting.

# combine.yml
    from_file: issues.json

Page variables

The other way to use variables is to define them on specific pages. This is often used to pass the values back to the template they are extending.

An example would be setting meta values in the <head> of your root template:

<!-- base.template.html -->
  {% if title is defined %}<meta property="og:title" content="{{ title }}" />{% endif %}

Setting variables in HTML

The Jinja {% set %} tag can be used in a single line:

<!-- my-page.html -->
{% extends "base.template.html" %}

{% set title = "My page title" %}

Or multi-line:

<!-- my-page.html -->
{% extends "base.template.html" %}

{% set title -%}
My page title
{%- endset %}

Setting variables in Markdown

In Markdown pages, you can set variables using YAML frontmatter.

title: My page title

My page content with frontmatter above it!

Built-in variables

There are a handful of variables that Combine sets automatically.


Automatically set to development when running combine work, and production when running combine build.


Automatically set to the current time of the build. This is the Python function and can be used in templates as {{ now().year }}, for example.


Used only in Markdown to determine which template to use for rendering the page. Set to markdown.template.html by default and can be overriden with frontmatter.


Automatically set to{port} in development, and is required by the absolute_url filter.


Automatically set to the URL of the current page when it is being built.