Markdown Toolbox Logo Markdown Toolbox
Home
Blog

How to Use Variables in Markdown

2024-11-11

Markdown itself does not support the direct use of variables like programming languages. However, you can use preprocessors or static site generators (like Jekyll or Hugo) to utilize variables.

Short Version

In Jekyll, you can use:

In Hugo, you can use:

Long Version

Introduction

When working on large documents or websites, hardcoding every piece of information can become tedious. Using variables allows you to dynamically insert and reuse specific pieces of data.

Utilizing Variables in Markdown

Since Markdown is designed to be a straightforward markup language, it doesn't natively support variables. However, by using tools like Jekyll, Hugo, or other static site generators, you can incorporate variables for dynamic content.


Examples

  • Jekyll: Use liquid template language to insert variables.

  • Hugo: Use Go template language for variables.