Dates

Defcustoms #

org-hugo-date-format #

Default value
"%Y-%m-%dT%T%z"

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).

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.

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).

NOTE
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 interpreted from the Org Special Property DEADLINE. The idea is that just as you ideally don’t plan to work on a task after a set deadline, you don’t plan to keep a post published after a set expiry date. This property is set using the default C-c C-d binding in Org.

Here’s an example:

* My short-lived post
DEADLINE: <2018-02-06 Tue>
Post content.

Above gets translated to expiryDate = 2018-02-06T00:00:00-05:00 in front-matter (TOML).

You do not then need to explicitly set 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.