Skip to content
← Back to Map layouts in QGIS: from template to automated map series
Map layouts · Part 07 of 18Beginner· 6 min readSources

Save a QGIS Print Layout as a Template and Reuse It

Save the finished layout as a .qpt template, make a new layout from it, and learn what a template keeps, what it leaves out, and how to test it in a fresh project.

You spent six pages building this layout. You should not have to do it again for the next map. A template is the layout saved as a file, so that you or anyone else can start from it. This is the idea behind the whole automation project: the design lives in the template, and only the content changes.

Here is the layout you are about to save.

The finished layout with title, subtitle, map with a coordinate frame, legend, locator map, scale bar, north arrow, a scale note and a source note
Figure 7.1. The layout from Part B so far, with every item named.

Every item has an ID. This is the list to check before you save:

IDWhat it is
main_mapThe main map
map_titleThe title
map_subtitleThe subtitle
main_legendThe legend
main_scale_barThe scale bar
north_arrowThe north arrow
map_creditsThe source note
locator_mapThe locator map
locator_labelThe label above the locator map
scale_noteThe scale text under the scale bar

Step 1: Save the layout as a template

In the layout window, choose Layout > Save as Template. Pick a folder and a name, for example parks_and_lakes_template.qpt.

The Layout menu in the Print Layout window with Save as Template highlighted
Figure 7.2. Layout > Save as Template.

Keep the template in a folder that you will remember, together with any logos or pictures that the layout uses. By default a template stores a link to a picture file and not the picture itself, so moving the picture breaks the link.

You can download the template from this page: parks_and_lakes_template.qpt. It is a text file in XML. You can open it in a text editor to see how it is built, but do not edit it by hand, because one wrong character makes the whole file unreadable.

Step 2: What a template keeps

A template keeps the design:

  • the page size and orientation
  • every item, with its position, size and appearance
  • item IDs, fonts, colours, frames and grids
  • expressions and data-defined settings
  • the way the legend is curated

It does not keep:

  • the data, since your layers stay in the project
  • the project settings, such as the CRS
  • pictures, only the link to them

One more thing deserves care. Locked layers and map themes refer to layers by an internal ID. If you load the template into a project where those layers are missing, the locked map shows nothing. Use the same layer names and the same data, or set the layers again after loading.

Step 3: Make a layout from a template

There are two ways.

A new layout from a template. Open Project > Layout Manager. At the bottom is the group New from Template.

The Layout Manager listing the layout Parks and lakes map, with the New from Template group below it showing Empty Layout, a Create button, a file path box and an Open template directory button
Figure 7.3. The Layout Manager. New from Template is at the bottom.

Change Empty Layout to Specific, press the button with three dots and choose your .qpt file. Press Create and give the new layout a name. QGIS builds it at once. The Open template directory buttons show the folder where QGIS looks for templates: put your template in the User folder, and it appears in the dropdown without browsing.

A layout window with a layout built from the template, with all items listed by ID in the Items panel
Figure 7.4. A new layout made from the template. All items and IDs are there.

Items from a template. If you already have a layout open and only want to add the items, choose Layout > Add Items from Template and pick the file. This is useful for adding a standard title block or a logo strip to a layout you have already started.

The Layout menu with Add Items from Template highlighted
Figure 7.5. Layout > Add Items from Template.

Step 4: Test the template before you rely on it

A template that works only on your own computer is a trap. Test it like this:

  1. Open the start project again, or a copy of it, so that you have a fresh project.
  2. Make a layout from the template, as in Step 3.
  3. Compare it with the original. Is anything missing, shifted or empty?
  4. Open the Items panel. Are all the IDs in the table above there?
  5. Export a PDF. Does it look like the original?

Write down what the template expects: which layers, by what names, and which items the script or the person using it will change. For this one it is the map, the title, the subtitle and the locator. A short note saves a lot of questions later.

Save the project.

When it breaks

What you seeWhyWhat to do
The map is empty after loading the templateThe locked layers or the theme are not in this projectOpen the map's Layers group and choose the layers again
QGIS says the template file is not validThe file was edited by hand or damagedSave the template again from the layout
A picture is missingThe template stored a link to a file that movedChoose the picture file again, and keep pictures next to the template
Item IDs are missingThe template was saved before you added themAdd the IDs in the original layout and save the template again
The legend is emptyThe legend's linked map is missingSet the linked map in its Main Properties

Make it your own

  1. Make a layout from the template and change the title. Does the original layout change too?
  2. Save a second template for A4 portrait. What would you have to change?
  3. Delete the map theme or layer used by the main map, then load the template. What do you see, and how do you repair it?

Common mistakes

  • Treating the template as if it contained the data.
  • Forgetting to give items IDs before saving.
  • Keeping logos in a folder that is later renamed.
  • Never testing the template in a fresh project.
  • Editing the .qpt file by hand.

Key takeaways

Next: A page with several maps.