Section vs Page

Hello, I’ve read this while looking for a way to get the section variables of the section a page is in.
For me this seems like a benefit of having pages belong to a section.

My simple use case is to have the {{ section.title }} included in the <title> element. So far it seems that a page simply forgets about its section. I see that there is get_section(), but it is a bit inconvenient to run it on every page!

While drafting this, I found the page.components variable has what I need. :slight_smile:

I found this trick useful for exploring what variables existed. In the template of a page:

{% set section = get_section(path="my_section/_index.md", metadata_only=true) %}

<h2>section vars</h2>
{% for key,value in section %}
<code>{{ key }} = {{ value }}</code><br>
{% endfor %}
            
<h2>page vars</h2>
{% for key,value in page %}
<code>{{ key }} = {{ value }}</code><br>
{% endfor %}

example output:

section vars

relative_path = blog/_index.md
content =
permalink = http://127.0.0.1:1111/blog/
ancestors = [_index.md]
title = List of blog posts
description =
extra = [object]
path = /blog/
components = [blog]
toc = []
word_count = 0
reading_time = 0
lang = en
assets = []
pages = []
subsections = []
translations = []

page vars

relative_path = blog/2021-02-23-my-blog-page.md
content = <p>Foo</p>
permalink = http://127.0.0.1:1111/blog/my-blog-page/
slug = my-blog-page
ancestors = [_index.md, blog/_index.md]
title = My blog page
description =
updated =
date = 2021-02-23
year = 2021
month = 2
day = 23
taxonomies = [object]
extra = [object]
path = /blog/my-blog-page/
components = [blog, my-blog-page]
summary =
toc = []
word_count = 1
reading_time = 1
assets = []
draft = true
lang = en
lighter =
heavier =
earlier = [object]
later =
translations = []