Profiling

Article last updated at August 11, 2026

The text is marked up using conditional operators or variables. During the build, only the required text fragments are inserted into each output document.

Project structure

  1. In the project root, create a folder common with the source files.

  2. In the project root, create folders for each document version. For example, android and ios for different platforms.

  3. In the document version folders, configure configuration files.

Example of the structure organization:

project_name
├── common  # папка с файлами проекта
│   ├── ru # языковая папка
│   │   ├── index.md
│   |   ├── presets.yaml
│   |   └── toc.yaml
|   └── en  # языковая папка
│       ├── index.md
│       ├── presets.yaml
│       └── toc.yaml
├── document_name_1  # Папка собираемого документа, например android, windows или tld-com
│   ├── .yfm
├── document_name_2
│   ├── .yfm
├── document_name_3
|   ├── .yfm

Step 1. Add variable presets

Create a presets.yaml file. The common file is located in the project root directory and contains all variables for each profiling condition.

Place the variable values that are set by default in the default preset. It is mandatory.

Place unique values in separate presets for each profiling condition.

Example of a presets.yaml file for different platforms
default: # набор значений по умолчанию
  locale: ru
  platform: browser

ios: # набор значений для ios
  platform: ios

android: # набор значений для android
  platform: android

Profiling conditions are usually called product, platform, audience, but you can use any other names adopted in your project.

Learn more

Step 2. Mark up the document text

The text is marked up using conditional operators or variables.

Warning

If the text is marked up using variables, then the presets.yaml file must contain presets for each profiling variant. During the build, variable values are taken from the default preset and the preset specified in the configuration file .yfm in the varsPreset parameter.

Profiling conditions can be composite. Multiple conditions are combined using the or or and operators.

Examples of markup with conditional operators

Three fragments that differ for each platform:

{% if platform == "ios" %}
Скачайте приложение в [App Store](https://www.apple.com/ios/app-store/).
{% endif %}

{% if platform == "android" %}
Скачайте приложение в [Google Play](https://play.google.com).
{% endif %}

{% if platform == "browser" %}
Откройте страницу в браузере.
{% endif %}

A fragment can belong to multiple platforms:

{% if platform == "ios" or platform == "android" %}
Скачайте приложение.
{% endif %}

A fragment should be displayed for a specific platform and only in the selected region:

{% if platform == "browser" and locale == "ru" %}
Откройте страницу example.ru.
{% endif %}

Step 3. Mark up the document table of contents

The document table of contents toc.yaml is marked up using the when conditional operator:

when: условие == "значение"
Examples

Two pages that are displayed for different platforms:

- name: Обзор iOS
  href: iOS-overview.md
  when: platform == "ios"
- name: Обзор Android
  href: android-overview.md
  when: platform == "android"

One page is displayed for multiple platforms:

- name: Обзор
  href: overview.md
  when: platform == "ios" or platform == "android"

A page should be displayed for a specific platform and only in the selected region:

- name: Обзор
  href: overview.md
  when: platform == "ios" and locale == "ru"

Step 4. Configure the configuration files

Configuration files are required for proper project build and publishing.

File .yfm

In the configuration file .yfm, add the following build parameters:

apply-presets: true
varsPreset: "имя-пресета"

In the varsPreset field, specify the preset name from step 1.