A certificate template is the page design of your certificate. To show the learner's name, the course title, the date or the result, you add a short code where it should appear. When a learner downloads the certificate, each code is replaced with the real value.

For security, only the codes on this page work. If you use another one, that spot simply shows the text you wrote there in the design, and the rest of the certificate prints as usual.

Show the learner's details

Copy the line you need into your template. The words between the tags, such as Learner name, are only what you see while designing; on the certificate, they are replaced by the real value.

To show

Copy this

The learner's name

<span th:text="${attendee}">Learner name</span>

The course or learning path title

<span th:text="${title}">Course title</span>

The author's name

<span th:text="${author}">Author</span>

The completion date

<span th:text="${#dates.format(completionDate, 'dd/MM/yyyy')}">Date</span>

The score, as a number such as 85

<span th:text="${score}">Score</span>

The result: PASS, FAIL, or PENDING while answers wait to be graded

<span th:text="${result}">Result</span>

The score and the result exist on course certificates only, not on learning path certificates. A course without questions has no score.

Date formats

Change the part in quotes to choose how the date looks, using letters, spaces and the characters: - / . only. Use the date code once per template.

Write

Shows

'dd/MM/yyyy'

26/11/2026

'MM/dd/yyyy'

11/26/2026

'dd.MM.yyyy'

26.11.2026

'd MMMM yyyy'

26 November 2026

'EEEE d MMMM yyyy'

Thursday 26 November 2026

Add your own words around a value

Put your words in single quotes and join them to the value with +. Or write the whole line between two vertical bars | |, with the codes inside.

To get

Copy this

Participant: Anna Smith

<p th:text="'Participant: ' + ${attendee}">Participant</p>

Awarded to Anna Smith for Safety Basics

<p th:text="|Awarded to ${attendee} for ${title}|">Award line</p>

Score: 85%

<p th:text="'Score: ' + ${score} + '%'">Score</p>

Show a line only in some cases

Use th:if to show a line only when something is true, and th:unless to show it only when it is not.

To

Copy this

Show a line only when the learner passed

<p th:if="${result} == 'PASS'">Congratulations, you passed!</p>

Show a line only when the learner did not pass

<p th:unless="${result} == 'PASS'">Thank you for taking part.</p>

Show the score only when there is one

<p th:if="${score} != null and ${score} != ''" th:text="'Score: ' + ${score} + '%'">Score</p>

Print one word or another

<p th:text="${result} == 'PASS' ? 'Passed' : 'Not passed'">Result</p>

Print a default when a value is missing

<p th:text="${author} ?: 'The training team'">Author</p>

== means "is", != means "is not", and you can combine conditions with and, or and not.

A complete example

This block puts everything together. Paste it into your template and adjust the words; the lines starting with <!-- are notes for you and do not appear on the certificate.

<!-- Learner and course -->
<p th:text="'Participant: ' + ${attendee}">Participant name</p>
<p th:text="|${title}, by ${author}|">Course title, by author</p>

<!-- Completion date in your own format -->
<p>Completed on <span th:text="${#dates.format(completionDate, 'd MMMM yyyy')}">date</span></p>

<!-- Score with a percent sign, only when there is a score -->
<p th:if="${score} != null and ${score} != ''" th:text="'Score: ' + ${score} + '%'">Score</p>

<!-- Result as a word -->
<p th:text="${result} == 'PASS' ? 'Passed' : 'Not passed'">Result</p>

<!-- A block per result, with a default -->
<div th:switch="${result}">
  <p th:case="'PASS'">Congratulations, you passed.</p>
  <p th:case="'FAIL'">You completed the course.</p>
  <p th:case="*">Your answers are being reviewed.</p>
</div>
CODE

What does not work

To keep certificates safe, some template features are switched off. If you use one, that spot shows the text you wrote there in the design instead.

  • Changing a value, for example, writing the name in capital letters or shortening the title.
  • Showing information other than the values listed in Show the learner's details.
  • Comparing numbers or calculating, for example "score above 80" or "score minus 5".
  • Repeating a block, linking to other pages, or including another template.
  • Any th: code other than th:text, th:if, th:unless, th:switch and th:case.
  • Inline codes written as [[...]]: they print as written.
  • Notes in <!-- -->: they never appear on the certificate.

Images and styling

Images, such as your logo or a signature, must be inside the template itself, not linked from a website. Convert the image to base64 text (search for "image to base64" to find a converter) and paste it like this:

<img src="data:image/png;base64,iVBORw0KGgo..."/>

Save photos and backgrounds as JPEG rather than PNG: they look the same on the certificate and are 5 to 10 times smaller.

  • An image linked from a web address is removed from the certificate.
  • You can style the certificate with CSS, in a <style> block or a style attribute. A background image in CSS must be pasted the same way: url(data:image/png;base64,...).
  • Scripts, embedded pages and links to stylesheets are removed.

If something does not look right

  • A line shows its design text instead of the value: Check the code against the tables above: a missing quote or vertical bar, a typo in a value name, or a feature from What does not work.
  • "The certificate template is invalid" when you preview or download: Look for = where you meant ==, two pieces of text without + between them, or a bracket that is not closed.
  • An apostrophe breaks a line, as in 'Learner's name': Write the line between vertical bars instead, |Learner's name: ${attendee}|, or use the typographic apostrophe ’.
  • "null" appears on a learning path certificate: Learning paths have no score or result: remove those codes from learning path templates, or show them only when they exist, as in Show a line only in some cases.
  • The preview shows empty spaces or ${score}: The preview has no learner, so it leaves the name, title and author empty. The downloaded certificate shows the real values.