Date Formats #

The EXPORT_DATE and other date-type properties support date in either the RFC3339 date-time format1 or the built-in Org time-stamp (default binding C-c .).

RFC3339 date-time examples
  • 2017-09-12
  • 2017-09-12T16:10:10 (data and time are separated by T)
  • 2017-09-12T16:10:10Z (UTC time zone)
  • 2017-09-12T16:10:10-04:00 (UTC-04:00 time zone)
Org time stamp example
  • <2020-05-17 Sun>

Defcustoms #

org-hugo-date-format #

Default value

This variable sets the date format used for exporting date front-matter parameters like date, publishDate, expiryDate, lastmod.

Note that the date format must match the date specification from RFC3339.

Examples of RFC3339-compatible values for this variable:

Value Example output
%Y-%m-%dT%T%z (default) 2017-07-31T17:05:38-04:00
%Y-%m-%dT%T 2017-07-31T17:05:38
%Y-%m-%d 2017-07-31

Do C-h v org-hugo-date-format for more information (within Emacs, once the ox-hugo package is loaded).

org-hugo-suppress-lastmod-period #

Default value

A suppressing period (in seconds) during which the lastmod parameter is not added to the front matter. The suppressing period is counted as a delta between the date and lastmod parameters.

If the value is 86400.0, the lastmod parameter will not be added to the front matter within 24 hours from the value of date parameter.

lastmod would be exported when you initially change the Org TODO state to DONE by saving the file automatically with the following conditions. Some users may not prefer this behavior.

Variable Value
org-hugo-auto-set-lastmod t
org-log-done time

In such case, you can suppress lastmod in the front-matter if you set org-hugo-suppress-lastmod-period to 60.0 or other appropriate value.

Note that this variable is effective only if auto-setting of the lastmod parameter is enabled i.e. if org-hugo-auto-set-lastmod or EXPORT_HUGO_AUTO_SET_LASTMOD is non-nil.

File-based Exports #

In Org files meant for file-based exports, you simply set a value for a #+hugo_FOO keyword (in most cases, for example #+date is one of the exceptions) to set the FOO parameter in the exported front-matter.

Table 1: Dates translation from Org meta-data to Hugo front-matter (file-based exports)
Org Hugo front-matter (TOML)
#+date: 2017-07-24 date = 2017-07-24
#+hugo_publishdate: 2018-01-26 publishDate = 2018-01-26
#+hugo_expirydate: 2999-01-01 expiryDate = 2999-01-01
#+hugo_lastmod: 2018-02-06 lastmod = 2018-02-06
#+hugo_auto_set_lastmod: t lastmod = <current date>

Subtree-based Exports #

The date meta-data can be set as Org properties in post subtrees, similar to the keywords set for File-based exports. But subtree-based exports allow an even concise way to set those dates.

Date #

This is interpreted from the Org Special Property CLOSED (see Org Info: Special Properties).

The CLOSED property is inserted once the post-subtree’s TODO state is set to DONE (C-c C-t), if the org-log-done variable is set to 'time (default is nil). This option can also be enabled on a per-file-basis with #+startup: logdone.

Here’s an example:

* DONE My post
CLOSED: [2018-01-23 Tue 14:10]
Post content.

Above gets translated to date = 2018-01-23T14:10:00-05:00 in front-matter (TOML).

Another variable org-log-done-with-time can be set to nil (default to t) if you would like the CLOSED time stamp to contain only the date, and not the time.

You do not then need to explicitly set the :EXPORT_DATE: property.

Publish Date #

This is interpreted from the Org Special Property SCHEDULED. The idea is that you schedule a task for a future date, just as you would set a post to be published in future. This property is set using the default C-c C-s binding in Org.

Here’s an example:

* My future post
SCHEDULED: <2060-01-26 Mon>
Post content.

Above gets translated to publishDate = 2060-01-26T00:00:00-05:00 in front-matter (TOML).

You do not then need to explicitly set the :EXPORT_HUGO_PUBLISHDATE: property.

Expiry Date #

This is set using the :EXPORT_HUGO_EXPIRYDATE: property.

Last modified #

Like any other front-matter property, you can explicitly set the last modified date too, using the :EXPORT_HUGO_LASTMOD: property.

But what’s the point of calling a property last modified, if you forget to manually update that property each time you update the post. SO ox-hugo takes care of that for you.. if you set the property :EXPORT_HUGO_AUTO_SET_LASTMOD: to a non-nil value.

It’s normal for one to choose to auto-set the last modified date for all the posts. So instead of setting the above property for each post individually, it might be more convenient to simply put #+hugo_auto_set_lastmod: t at the top of the file.

But note that if the lastmod date is parsed from the :LOGBOOK: drawer that value will take precedence, and the “auto set lastmod” feature will be disabled.

  1. The TOML date-time uses the same RFC3339 format. ↩︎

Fork me on GitHub