{# title = More About Contexts #} {# foo = 1234.5 #} {# bar = [ 100, 200, "Hello World" ] #} {{ page.title }} {% assets %} {% markdown %} # {{ page.title }} The word "context" refers to data that can be used during the rendering of a page. ### Default Context There are two ways to get context into each page. The first is via template comments. Writing {% verbatim %} {# title = More About Context #} {% endverbatim %} at the top of the HTML page will create the variable title that can be used in the page as {% verbatim %}{{ page.title }}{% endverbatim %} to produce: {{page.title}} To add more variables list them one on each line. To add data beyond a simple string use the JSON format: {% code "django-comments" %} Note that in the last example for bar gets turned into python list accessible as {% verbatim %}{{ page.bar }} {% endverbatim %} to produce {{page.bar}}. The {% verbatim %}{{ page.bar }} {% endverbatim %} object can also be looped over with Django to produce: {% for elem in page.bar %} * {{ elem }} {% endfor %} ### Advanced Context The second method of getting context into a page is a python module named context.py placed in the directory root. This may contain any python construct. Make sure that this python module can be executed without errors. The content of this module will be visible under the parameter data {% verbatim %}{{ context }}{% endverbatim %} variable name. Example supposed that the `context.py` file contains the following: {% code "context.py" lang='python' %} This file has to be in the root location of the site. We can now access the contents of this module via `context` variable like so {% verbatim %}{{ context.greeting }}{% endverbatim %} will produce: {{ context.greeting }} Go back to: {% link "index.html" "Home Page" %}. {% endmarkdown %}