A template builds a page's body. A section group builds the shared header and footer that wrap every page. It's a JSON file in sections/, like sections/header.json. The layout renders it with {% sections 'header' %}.
{# in layout/theme.liquid #}
{% sections 'header' %}
{{ content_for_layout }}
{% sections 'footer' %}
Edit the header group and it changes on every page. To change it on some pages only, render a different group via an alternate layout (which you just met).