Aller au contenu

Write a theme

Ce contenu n’est pas encore disponible dans votre langue.

You can write your own theme to customize the look and feel of your CV. It becomes easy to create themes, switch between them, and share with the community.

The theme must be located in the themes directory in the current working directory. Here is an example of the directory structure:

themes
└── <my-theme-name>
├── theme.yaml # Theme metadata (required)
├── index.html # Theme template (required)
├── sample.yml # Demo CV data for screenshots (recommended)
└── preview.png # Preview image for the theme library (recommended)

You can initialize a new theme with the following command:

cvwonder themes create --name "My Theme"

This command creates a new directory in the themes/ folder named after the slug of the theme name (themes/my-theme/ here) and initializes the following files:

  • theme.yaml — theme metadata
  • index.html — starter template
  • sample.yml — minimal demo CV data for screenshot generation

The sample.yml file provides demo CV data used for screenshot generation. It is automatically created when you run themes create and follows the same YAML structure as your main cv.yml.

CVWonder uses this file as the CV source when generating a theme preview, so it should demonstrate the theme’s layout and design well.

person:
name: Jane Doe
profession: Software Engineer
location: Paris, France
email: jane.doe@example.com
phone: "+1 555 000 0000"
experience:
since: 2018
career:
- companyName: Example Corp
missions:
- position: Senior Engineer
company: Example Corp
location: Paris, France
dates: "2020 - Present"
summary: Led development of core platform services.
description:
- Designed and implemented microservices architecture.
- Mentored junior engineers.
technologies:
- Go
- Docker

Generate a preview.png image for your theme using the themes screenshot command:

cvwonder themes screenshot my-theme

Aliases: themes ss

The screenshot is captured at 1280×900 px with 2× device scale (retina quality), producing a 2560×1800 PNG at themes/my-theme/preview.png.

CV source resolution order:

  1. themes/<theme>/sample.yml — theme-specific demo data (recommended)
  2. ./cv.yml — the root CV file as fallback
  3. Fatal error if neither is found

Add a theme.yaml file at the root of the theme directory which contains the theme metadata.

name: My Wonderful Theme
slug: my-wonderful-theme
description: A wonderful theme for your CV
author: Germain
Key Description
name The name of the theme
slug The slug of the theme. It is used to name your directory in the themes/ folder.
description A short description of the theme
author The author of the theme
minimumVersion The minimum version of cvwonder required to use the theme.

Themes can expose a set of configurable options that users can override at generation time. Declare default values in the configuration: block of theme.yaml:

name: My Wonderful Theme
slug: my-wonderful-theme
description: A wonderful theme for your CV
author: Germain
configuration:
displayName: true
person:
anonymisation: false
socialNetworks:
display: true

Configuration values are available in the template under the .Config variable:

{{ if index .Config "displayName" }}
<h1>{{ .Person.Name }}</h1>
{{ end }}
{{ if index .Config "person" }}
{{ $person := index .Config "person" }}
{{ if index $person "anonymisation" }}
<h1>Anonymous</h1>
{{ else }}
<h1>{{ .Person.Name }}</h1>
{{ end }}
{{ end }}

Overriding configuration at generation time

Section titled “Overriding configuration at generation time”

Users can override any configuration value at runtime with the --config flag on the generate or serve commands:

# Override a top-level key
cvwonder generate --config "displayName=false"
# Override a nested key using dot-notation
cvwonder generate --config "person.anonymisation=true"
# Multiple overrides
cvwonder generate --config "displayName=true" --config "person.anonymisation=false"

Values are automatically coerced: "true" / "false" become booleans, plain integers like "5" become numbers, everything else stays a string.

CLI overrides are deep-merged on top of the defaults declared in theme.yaml: sibling keys are preserved, only the specified leaf is replaced.

The templated file is located at themes/<my-theme-name>/index.html and stands as the entry point for the theme.

The templating engine is the template/html go package.

The input CV data is formerly structured to make it easy to use in the template. In order to help you write the data, a JSON Schema is provided in the schema directory.

For example, the dv data contains the details of the CV owner:

[...]
person:
name: Germain
profession: Bâtisseur de Plateformes et de Nuages
experience:
years: 10
since: 2014
[...]

Which can be used in the template like this:

<h1>{{ .Person.Name }}</h1>
<h2>{{ .Person.Profession }}</h2>
{{ if .Person.Experience.Years }}
<p>{{ .Person.Experience.Years }} years of experience</p>
{{ end }}
{{ if .Person.Experience.Since }}
<p>Since {{ .Person.Experience.Since }}</p>
{{ end }}

Every entity in the CV data model (.Person, .Company, .SocialNetworks, each .Career[] entry and its .Missions[], .TechnicalSkills, each .TechnicalSkills.Domains[] and its .Competencies[], each .SideProjects[], .Certifications[], .Education[], .References[] and .Languages[] entry, and the CV root itself) exposes an optional .Custom field: an ordered list of {Label, Value} entries that authors add by hand in cv.yml for data the model has no dedicated field for.

The CV root also exposes .CustomSections, an ordered list of whole sections the model has no name for at all. Each entry has a Title and its own Fields list, using the same {Label, Value} shape:

person:
name: Germain
custom:
- label: Availability
value: Immediate
customSections:
- title: Publications
fields:
- label: Distributed Systems at Scale
value: 2023

A minimal example that iterates a .Custom list:

{{ range .Person.Custom }}
<p>{{ .Label }}: {{ .Value }}</p>
{{ end }}

And a .CustomSections example:

{{ range .CustomSections }}
<h2>{{ .Title }}</h2>
{{ range .Fields }}
<p>{{ .Label }}: {{ .Value }}</p>
{{ end }}
{{ end }}

Value may be a plain scalar (string, number, boolean), a list, or a nested object — whatever shape the author wrote in YAML, with no type constraint enforced by cvwonder. cvwonder does not provide a helper to detect a value’s shape; themes that only render scalars can simply print {{ .Value }}, and a theme choosing to also support a known list-shaped value is responsible for ranging over it directly with the existing template constructs:

{{ range .Person.Custom }}
{{ if eq .Label "Topics" }}
<ul>
{{ range .Value }}<li>{{ . }}</li>{{ end }}
</ul>
{{ else }}
<p>{{ .Label }}: {{ .Value }}</p>
{{ end }}
{{ end }}

To enable the watch feature on CV Wonder, you have to inject an internal js script in the template. This script will automatically reload the page when the CV data or the Theme is updated.

<script src="http://localhost:35729/livereload.js"></script>