# Build a certificate template

A certificate template is the design PiGi renders into a PDF and image when a tandem flight completes or a student graduates a course. Build one at Certificates → Templates, either in the drag-and-drop Block Editor or by writing HTML with placeholders such as {{ student_full_name }}.

Source: https://help.pigi.io/guides/courses/certificates/certificate-templates

## Quick answers

**Where do I create a certificate template?**
**Certificates → Templates** at /school/admin/certificates/templates, then click
**+ Template**. You are asked to choose **Block Editor** or **HTML** before the
editor opens.

**Can I change from HTML to the Block Editor later?**
No. The chooser says so: "Drag-and-drop blocks, or write the HTML yourself. This
can't be changed after the template is created." Create a new template instead.

**How do I get a starting template?**
When the template list is empty, a **Load default templates** button appears in
the middle of the page. It offers **Tandem Paragliding Certificate**. Loading is
idempotent — running it twice does not duplicate the template.

**Where do I set the template name?**
Inside the editor, click **Settings** in the header. The **Template details**
drawer holds **Name**, **Description**, and — once the template has been saved
once — **School logo** and **Image** uploads.

**What placeholders can I use?**
Open the **Placeholders** tab in the right-hand panel and click one to insert it
at the cursor. For a tandem certificate the generator supplies `company_name`,
`school_name`, `company_logo_url`, `school_logo`, `student_id`,
`student_full_name`, `instructor_id`, `instructor_full_name`,
`instructor_signature`, `flying_site_location_and_country`,
`compliance_document_names_and_codes` and `issue_date`. For a course certificate
it supplies `student_full_name`, `course_name`, `school_name`,
`school_caa_dto_number`, `instructor_name`, `instructor_signature`,
`company_logo_url`, `school_logo`, `issue_date` and `completion_date`.

**Do templates support if-statements or loops?**
Only a simple `{% if name %}…{% endif %}` around a plain placeholder name. There
is no `{% else %}`, no loops, and no filters or expressions. Anything else in
`{% … %}` is stripped out before rendering.

**Why does my certificate fail to generate?**
Because the template uses a placeholder name the generator does not supply for
that kind of certificate — a typo, or a course placeholder on a tandem
template. Generation stops with "Template '&lt;name&gt;' is missing values for: …".
A placeholder the generator *does* supply but which is empty for that record —
a school with no logo, an instructor who never uploaded a signature — is fine:
it renders as a blank on the page.

**How do I preview a template?**
In HTML mode the editor has two tabs, **HTML** and **Preview**. The preview
substitutes your uploaded **School logo** and **Image** so you see the real
artwork. In Block Editor mode the canvas is the preview.

**Where do the uploaded logo and image go?**
They fill the `{{ school_logo }}` and `{{ image }}` placeholders. Both uploads
only appear in the **Template details** drawer after the template has been saved
once.

## What this is

A certificate template holds the artwork and wording of one certificate. PiGi
never designs a certificate per student — it renders this one template against a
context of values (the student's name, the site, the date) into a PDF and a
preview image, stores both, and links them to the student's record.

Templates are inert on their own. What decides when a template is used is a
separate rule, the certificate requirement, which says "generate this template
when a tandem flight completes" or "…when a course completes".

## Before you start

- You need the company admin role.
- Decide between the Block Editor and HTML before you start — the choice is
  permanent per template.
- Have your logo artwork ready if the design needs it.

## Steps

1. Open **Certificates → Templates** at /school/admin/certificates/templates.
2. Click **+ Template**. The **New Template** chooser appears.
3. Pick **Block Editor** or **HTML**.
4. Click **Settings** in the editor header and fill in **Name** and
   **Description** in the **Template details** drawer.
5. Design the certificate. In HTML mode, use the **HTML** tab to write and the
   **Preview** tab to check.
6. Use the **Placeholders** panel on the right to insert values. Click a
   placeholder to drop `{{ name }}` in at the cursor.
7. Click **Save**.
8. Re-open **Settings** to upload the **School logo** and **Image** now that the
   template exists.
9. Switch to the **Generate for** tab in the right panel and click **Add model**
   to say when this certificate is issued.

## Fields

| Field | Required | What to enter |
|---|---|---|
| Name | Yes | The template's name, shown in the list and used in the generated filename. |
| Description | No | A note for your own team. |
| School logo | No (edit only) | Fills `{{ school_logo }}`. |
| Image | No (edit only) | Fills `{{ image }}`. |
| HTML | Yes (HTML mode) | The certificate markup with `{{ placeholder }}` values. |

## Known limitations

- **The editor type is locked in at creation.**
- **Only one default template ships.** "Load default templates" offers just
  **Tandem Paragliding Certificate**. It works as-is now that the tandem
  generator supplies `{{ company_logo_url }}` and `{{ company_name }}`.
- **A placeholder that no generator supplies still fails the whole render.**
  Only genuinely unknown names do — a placeholder that is supplied but empty
  for this record (a school with no logo, an instructor with no signature)
  renders as a blank on the page rather than killing the certificate.
- **The template list shows only the Name column.** There is no indication of
  which templates have a **Generate for** rule, or how many certificates they have
  produced.
- **The Block Editor autosaves every 10 seconds** on an existing template. In
  HTML mode nothing is saved until you click **Save**.
- **The Preview iframe is not a true render.** The final PDF is produced
  separately, so fonts and page size can differ from the browser preview.

## Related

- [Decide when a certificate is issued](certificate-requirements.md)
- [Find an issued certificate](issued-certificates.md)
- [Graduate a student](graduate-a-student.md)
