Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Get yaml-data into md-files

Started by Muut Archive 11 years ago · 2 replies · 321 views
11 years ago

where should a yaml-file sit if i want to call it from within a md-file?

and how do I call its contents into a page? thaaaaaaaaaanks :D

11 years ago

YAML files just provide configuration data. All of these will require Grav processing to be enabled on the page (off by default). See Content Headers docs for details on how to do this.

In Grav you have several options for where to put YAML data:

TXT
my_var: foo

1) You can put YAML data in the page header itself. This is the simplest method, and you can then access the data in the page itself with Twig:

TWIG
{{ header.my_var }}

2) Put the YAML data in your user/config/site.yaml and access from the page with:

TWIG
{{ site.my_var }}

3) Create a brand new yaml file with any name in user/config eg: user/config/myfile.yaml

TWIG
{{ config.myfile.my_var }}

The choice is yours!

11 years ago

merci you are great. thanks for explanation ! :D

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1319 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4045 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago