arrow_back
Back

Hugo configuration: config.toml, site title, and baseURL

Andrew Dorokhov Andrew Dorokhov schedule 2 min read
menu_book Table of Contents

For configuration answers the config.toml file.

baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'

Hugo’s internal functions use the baseURL value to build absolute URLs. If you have a domain name for your site you should change this value to reflect that domain.

The title value is where you’ll store the site’s title.

Custom params

Built-in fields like title are not enough for every site. Put your own values under [params]:

[params]
  author = "Andrew Dorokhov"
  description = "My website"

In layouts:

{{ .Site.Params.author }}
{{ .Site.Params.description }}

A permalink is the permanent URL of a page. Override it per page with the url field in front matter.

For many pages at once, define rules in config.toml:

[permalinks]
posts = "posts/:year/:month/:slug/"

That yields URLs like /posts/2020/01/first_post. The slug comes from the title by default, or from a slug field in front matter.

Year / month archives

Hugo does not generate date-based archive list pages out of the box. A common workaround is to put year and month in front matter:

year: "2020"
month: "2020/01"

Register them as taxonomies (and keep tags/categories explicitly — defining [taxonomies] replaces the defaults):

[taxonomies]
year = "year"
month = "month"
tag = "tags"
category = "categories"

[permalinks]
year = "posts/:slug/"
month = "posts/:slug/"

The default list layout then renders /posts/<year> and /posts/<year>/<month>.

code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Hugo templates: layouts, partials, and Go html/template

arrow_forward