Need help with hugo-clarity?
Click the β€œchat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

262 Stars 155 Forks Other 535 Commits 15 Opened issues


A theme for Hugo based on VMware Clarity

Services available


Need anything else?

Contributors list

Hugo Clarity

A technology-minded theme for Hugo based on VMware's open-source Clarity Design System featuring rich code support, dark/light mode, mobile support, and much more. See a live demo at

Clarity Hugo Theme

Preview on Desktop

| Light Mode | Dark Mode | |---| --- | | Clarity Hugo Theme desktop light | Clarity Hugo Theme desktop dark |

Preview on Mobile

| Light Mode | Dark Mode | |---| --- | | Clarity Hugo Theme mobile light | Clarity Hugo Theme mobile dark |

Table of Contents


  • Blog with tagging and category options
  • Deeplinks
  • Native Image Lazy Loading
  • Customizable (see config)
  • Dark Mode (with UI controls for user preference setting)
  • Toggleable table of contents
  • Flexible image configuration
  • Logo alignment
  • Mobile support with configurable menu alignment
  • Syntax Highlighting
  • Rich code block functions including:

    1. Copy to clipboard
    2. Toggle line wrap (dynamic)
    3. Toggle line numbers
    4. Language label
    5. Toggle block expansion/contraction (dynamic)

    To put it all in context, here is a preview showing all functionality.

    code block functions


Firstly, ensure you have installed the extended version of Hugo. See installation steps from Hugo's official docs.

Getting up and running

Read the prerequisites above and verify you're using the extended version of Hugo. There are at least two ways of quickly getting started with Hugo and the VMware Clarity theme:

Option 1 (recommended)

Generate a new Hugo site and add this theme as a Git submodule inside your themes folder:

hugo new site yourSiteName
cd yourSiteName
git init
git submodule add themes/hugo-clarity
cp -a themes/hugo-clarity/exampleSite/* .

Then run

hugo server


Option 2 (Great for testing quickly)

You can run your site directly from the

. To do so, use the following commands:
git clone
cd hugo-clarity/exampleSite/
hugo server --themesDir ../..

Although, option 2 is great for quick testing, it is somewhat problematic when you want to update your theme. You would need to be careful not to overwrite your changes.

Option 3 (The new, most fun & painless approach)

This option enables you to load this theme as a hugo module. It arguably requires the least effort to run and maintain your website.

Ensure you have

binary installed on your machine Note: Mac users:
brew install go
git clone clarity
cd clarity/exampleSite/
hugo mod init my-site
cd ..
cp -a exampleSite/* .

Open config.toml file in your code editor, replace

theme = "hugo-clarity"
theme = [""]
or just
theme = ""

Hurray you can now run

hugo server

To pull in theme updates, run

hugo mod get -u ./...
from the theme folder. If unsure, learn how to update hugo modules

There is more you could do with hugo modules, but this will suffice for our use case here.


If set, jump over to the

file and start configuring your site.

This section will mainly cover settings that are unique to this theme. If something is not covered here (or elsewhere in this file), there's a good chance it is covered in this Hugo docs page.

Global Parameters

These options set global values that some pages or all pages in the site use by default.

| Parameter | Value Type | Overridable on Page | |:---- | ---- | ---- | | author | map / string | no | | twitter | string | no | | largeTwitterCard | boolean | no | | gaanalytics | string | no | | baiduanalytics | string | no | | plausibleanalytics | boolean | no | | matomoanalytics | boolean | no | | description | string | yes | | introDescription | string | no | | introURL | string/false | no | | numberOfTagsShown | integer | no | | fallBackOgImage | file path (string) | no | | codeMaxLines | integer | yes | | codeLineNumbers | boolean | yes | | mainSections | array/string | no | | centerLogo | boolean | no | | logo | file path (string) | no | | iconsDir | dir path (string) | no | | mobileNavigation | string | no | | figurePositionShow | boolean | yes | | figurePositionLabel | string | no | | customCSS | array of file path (string) | no | | customJS | array of file path (string) | no | | enforceLightMode | boolean | N/A | | enforceDarkMode | boolean | N/A | | titleSeparator| string | no | | showShare | boolean | yes | | comments | boolean | yes | | numberOfRecentPosts | integer | no | | numberOfFeaturedPosts | integer | no | | dateFormat | string | no | | enableMathNotation | boolean | yes | | customFonts | boolean | no | | since | integer | N/A | | rsssummary | boolean | N/A | | rsssummaryreadmore_link | boolean | N/A | | footerLogo | string | N/A |

Page Parameters

These options can be set from a page frontmatter or via archetypes.

| Parameter | Value Type | Overrides Global | |:---- | ---- | ---- | | title | string | N/A | | date | date | N/A | | description | string | N/A | | draft | boolean | N/A | | featured | boolean | N/A | | tags | array/string | N/A | | categories | array/string | N/A | | toc | boolean | N/A | | thumbnail | file path (string) | N/A | | featureImage | file path (string) | N/A | | shareImage | file path (string) | N/A | | codeMaxLines | integer | yes | | codeLineNumbers | boolean | yes | | figurePositionShow | boolean | yes | | figurePositionLabel | string | no | | comments | boolean | yes | | enableMathNotation | boolean | yes | | showDate | boolean | N/A | | showShare | boolean | N/A | | showReadTime | boolean | N/A | | sidebar | boolean | N/A | | singleColumn | boolean | N/A |

Modify Menus

Main Menu

To add, remove, or reorganize top menu items, edit the files here. Specifically look for items with


If you prefer the more traditional approach, delete

folder and enter a main menu entry inside the

Social media

To edit your social media profile links, edit the files referenced above. Specifically, look for items with


If you wish to globally use a large Twitter summary card when sharing posts, set the global parameter


Web site analytics

If using Google Analytics, configure the

global parameter in your site with your ID.

If using Baidu Analytics, configure the

global parameter in your site with your ID.

If using Plausible Analytics, configure the

global parameters in your site with the following.

To enable plausible analytics change to

Set domain name of your website, most cases same as your base URL this is required.

Default is set to, this parameter is only required if plausible is self-hosted.

Default is set to plausible, this parameter is only required if using a custom name for script.

If using Matomo Analytics, configure the

global parameters in your site with the following.

To enable matomo analytics change to

Set the domain name of your website, in most cases same as your base URL this is required.

Set to Matomo domain

Default is set to 1, change this to the siteid being tracked

Blog directory


and change the
key. Values will be directories where the blogs reside.
mainSections = ["posts", "docs", "blogs"]

For more info, see the Hugo docs.

Mobile menu positioning

The navigation menu when mobile browsing can be configured in

to open right or left depending on preference. The "hamburger" menu icon will always display in the upper right hand corner regardless.
mobileNavigation = "left" # Mobile nav menu will open to the left of the screen.

Tags and Taxonomies

Show number of tags

The number of tags and taxonomies (including categories) that should be shown can be configured so that any more than this value will only be accessible when clicking the All Tags button. This is to ensure a large number of tags or categories can be easily managed without consuming excess screen real estate. Edit the

parameter and set accordingly.
numberOfTagsShown = 14 # Applies for all other default & custom taxonomies. e.g categories, brands see

Number of tags example



Image figure captions

You have the option of adding captions to images in blog posts and automatically prepending a desired string such as "Figure N" to the alt text. This is controlled via two global settings.

is a string which will be prepended to any alt text of an article image. By default, this is set to "Figure." And
controls, globally, whether to show this label. It does not affect whether to show the image alt text, only the prefix figure caption. For more granular control,
can be overridden at the article level if desired.

The number will be automatically calculated and assigned after the

text starting from the top of the article and counting down. Featured images will be excluded from this figuration.

Image figure captions example

In this example,

is set to "Figure" in
and this is the first image in a given article.
![Antrea Kubernetes nodes prepared](./images/image-figure.png)

Here is my alt text for this image.

NOTE: Alt text with double quotes will produce broken HTML per limitations with Markdown. It is recommended to omit any quotations from your alt text.

Inline images

To make a blog image inline, append

to its alt text. Typically, inline images will have no alt text associated with them.

Inline images example


some alt text:inline

Inline image example

Float images to the left

To align a blog image to the left, append

to its alt text. Article text will then flow to the right of the image.

Float images left example


some alt text:left

Round borders for images

To make the image borders round, append

to its alt text. This is a pre-defined image class commonly used to display portrait images. Note that round is just another class and it can be mixed with other classes separated by space.

Round borders for images example


some alt text::round


Add classes to images

To add a class image to the left, append

to its alt text. You can also add multiple classes to an image separated by space.

Image class example


some alt text::img-large img-shadow

Article thumbnail image

Blog articles can specify a thumbnail image which will be displayed to the left of the card on the home page. Thumbnails should be square (height:width ratio of

) and a suggested dimension of 150 x 150 pixels. They will be specified using a frontmatter variable as follows:
thumbnail: "images/2020-04/capv-overview/thumbnail.jpg"

The thumbnail image will take precedence on opengraph share tags if the shareImage parameter is not specified.

Article featured image

Each article can specify an image that appears at the top of the content. When sharing the blog article on social media, if a thumbnail is not specified, the featured image will be used as a fallback on opengraph share tags.

featureImage: "images/2020-04/capv-overview/featured.jpg"

Share Image

Sometimes, you want to explicitly set the image that will be used in the preview when you share an article on social media. You can do so in the front matter.

shareImage = "images/theImageToBeUsedOnShare.png"

Note that if a share image is not specified, the order of precedence that will be used to determine which image applies is

. When sharing a link to the home page address of the site (as opposed to a specific article), the
will be used.

Align logo

You can left align or center your site's logo.

centerLogo = true # Change to false to align left

If no logo is specified, the title of the site will appear in its place.


Display line numbers

Choose whether to display line numbers within a code block globally with the parameter

setting to
codeLineNumbers = true # Shows line numbers for all code blocks globally.

Limit code block height

You can globally control the number of lines which are displayed by default for your code blocks. Code which has the number of lines exceed this value will dynamically cause two code block expansion buttons to appear, allowing the user to expand to full length and contract. This is useful when sharing code or scripts with tens or hundreds of lines where you wish to control how many are displayed. Under params in

file, add a value as follows:
codeMaxLines = 10 # Maximum number of lines to be shown by default across all articles.

If the value already exists, change it to the desired number. This will apply globally.

If you need more granular control, this parameter can be overridden at the blog article level. Add the same value to your article frontmatter as follows:

codeMaxLines = 15 # Maximum number of lines to be shown in code blocks in this blog post.


is specified both in
and in the article frontmatter, the value specified in the article frontmatter will apply to the given article. In the above example, the global default is
and yet the article value is
so code blocks in this article will auto-collapse after 15 lines.


is not specified anywhere, an internal default value of
will be assumed.

Table of contents

Each article can optionally have a table of contents (TOC) generated for it based on top-level links. By configuring the

parameter in the article frontmatter and setting it to
, a TOC will be generated only for that article. The TOC will then render under the featured image.

Table of contents (TOC) example

Article table of contents

Custom CSS and JS

To minimize HTTP requests per page, we would recommend loading CSS styles and JavaScript helpers in single bundles. That is to say, one CSS file and one JavaScript file. Using Hugo minify functions, these files will be minified to optimize the size.

Going by the above πŸ‘†πŸ» reason, we recommend adding custom CSS and JS via these files:

  1. _override.sass
    . This file should only be used to override sass & css variables e.g theme colors
  2. _custom.sass
    . This file should only be used to override everything else except sass & css variables.
  3. custom.js

Pro Tip: Ensure that your changes are git trackable by creating these files outside the theme directory. That is, at the root level of your site's directory. See tree below.

β”œβ”€β”€ yourSite
β”‚   β”œβ”€β”€ archetypes
β”‚   β”‚   └──
β”‚   β”œβ”€β”€ assets
β”‚   β”‚   β”œβ”€β”€ js
β”‚   β”‚   β”‚   └── custom.js
β”‚   β”‚   └── sass
β”‚   β”‚       β”œβ”€β”€ _custom.sass
β”‚   β”‚       └── _override.sass
β”‚   β”œβ”€β”€ config
β”‚   β”‚   └── _default
β”‚   β”‚       β”œβ”€β”€ config.toml
β”‚   β”‚       β”œβ”€β”€ configTaxo.toml
β”‚   β”‚       β”œβ”€β”€ languages.toml
β”‚   β”‚       β”œβ”€β”€ markup.toml
β”‚   β”‚       β”œβ”€β”€ menus
β”‚   β”‚       β”‚   β”œβ”€β”€ menu.en.toml
β”‚   β”‚       β”‚   └──
β”‚   β”‚       └── params.toml
β”‚   β”œβ”€β”€ content
β”‚   β”‚   β”œβ”€β”€

However, sometimes you may need to load additional style or script files. In such cases, you can add custom

files by listing them in the
file (see the snippet below). Similar to images, these paths should be relative to the
customCSS = ["css/custom.css"] # Include custom CSS files
customJS = ["js/custom.js"] # Include custom JS files


This theme includes functionality to display some "hightlight blocks" - called "notices" using a shortcode.

For example, see the shortcode markup below will render as a notice:

{{% notice note "Note Title" */%}}
This will be the content of the note.
{{% /notice %}}

For more examples see the "Notices" page in the


Forcing light or dark mode

By default, sites authored using Clarity will load in the browser with the user's system-wide settings. I.e., if the underlying OS is set to dark mode, the site will automatically load in dark mode. Regardless of the default mode, a UI control switch exists to override the theme mode at the user's discretion.

In order to override this behavior and force one mode or another, add either

to your
file. If neither value is present, add it.

To enforce Light Mode by default, turn


To enforce Dark Mode by default, turn

enforceLightMode = true # Force the site to always load in light mode.

Please note that you cannot enforce both modes at the same time. It wouldn't make sense, would it?

⚠️ Please also note that the mode toggle UI will remain in place. That way, if a user prefers dark mode, they can have their way. The best of both worlds.


This theme supports Multilingual (i18n / internationalization / translations)


gives you some examples already. You may extend the multilingual functionality by following the official documentation.

Things to consider in multilingual:

  • supported languages are configured in config/_default/languages.toml
  • add new language support by creating a new file inside i18n directory. Check for missing translations using
    hugo server --i18n-warnings
  • taxonomy names (tags, categories, etc...) are translated in i18n as well (translate the key)
  • menus are translated manually in the config files config/_default/menus/menu.xx.toml
  • menu's languages list are semi-hardcoded. You may chose another text for the menu entry with languageMenuName. Please, do better and create a PR for that.
  • content must be translated individually. Read the official documentation for information on how to do it.

note: if you do NOT want any translations (thus removing the translations menu entry), then you must not have any translations. In the exampleSite that's as easy as removing the extra translations from the

or executing this one-liner:
sed '/^\[pt]$/,$d' -i config/_default/languages.toml && rm config/_default/menus/

To change the values of translatable text, such as

, edit the values in the language file you are using in the
directory. If you have no such directory, copy the one inside the theme to your root Hugo directory.


Clarity provides some hooks for adding code on a page.

If you need to add some code (CSS import, HTML meta or similar) to the head section on every page, add a partial to your project:


Similar, if you want to add some code right before the body end (e.g fonts' links), create your own version of the following file:



Clarity supports Hugo built-in Disqus partial. You can enable Disqus simply by setting

in your configuration file.

You can also override layouts/partials/comments.html to take advantage of disqus comments Alternatives for details.

Please leave

#disqusShortname = ""
commented out if you decide to use other comments tools

You can disable them site-wide by setting

comments = false
from config.toml file and vice versa. Omitting that setting will default to comments will be enabled.

You can override these setting from each post individually. For example, you may want to disable/enable comments on specific posts. Use the same syntax used on the config.toml file.

please use

and not

Math notation

Clarity uses KaTeX for math type setting if

is set to
in global or page parameters (the latter takes precedence).

Also see supported TeX commands in KaTeX.

If you want chemical typesetting provided by the

extension, first copy

# cd /path/to/site
mkdir -p layouts/partials && cp themes/clarity/layouts/partials/math.html layouts/partials/math.html

Then add the corresponding line as its README suggested (without the


The added line should be before

and after


The new version of MathJax has comparable performance to KaTeX and better support for TeX commands.

If you prefer MathJax, create a blank

and add the following two lines:

This file will take precedence over the one Clarity provides and the site will load MathJax instead of KaTeX.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.