The author
front-matter parameter is designed to always be a list
or an array, so that multiple authors can be supported.
Default Author #
The author
parameter is set to always export by default (as the
default value of org-export-with-author
is t
).
The author name defaults to user-full-name
. You can choose to either
customize this variable in your Emacs config, or manually set the
author name by adding the below to the top of your Org file:
#+author: FirstName LastName
If using per-subtree flow, and if you want to specify the author (or
override the value set by the above #+author
keyword) differently
for all posts under a subtree, add below in that subtree’s property
drawer:
:PROPERTIES:
:EXPORT_AUTHOR: Firstname LastName
:END:
Either of above two author-setting methods will export to this TOML front-matter:
author = ["FirstName LastName"]
Multiple Authors #
Multiple authors can be specified by either:
- Using multiple
#+author
keywords, or#+author: FAuthor1 LAuthor1 #+author: FAuthor2 LAuthor2
- Specifying comma-separated authors, if setting them in subtree
properties.
:PROPERTIES: :EXPORT_AUTHOR: FAuthor1 LAuthor1, FAuthor2 LAuthor2 :END:
Either of above two author-setting methods will export to this TOML front-matter:
author = ["FAuthor1 LAuthor1", "FAuthor2 LAuthor2"]
Disabling exporting of author
parameter #
Author exporting can be disabled using any of these ways:
- To disable author exporting only for a specific Org file, add below
to the top of that file:
#+options: author:nil
- If using per-subtree flow, and if you want to disable author
exporting only for posts under specific subtrees, add below in the
property drawers of those:
:PROPERTIES: :EXPORT_OPTIONS: author:nil :END:
- To disable author exporting by default for all exporters (not just
ox-hugo
), setorg-export-with-author
tonil
in your Emacs config.
Tweaking your Hugo template to support list author
#
The author
front-matter parameter is always exported as a
TOML/YAML list.
If you have Hugo posts with the author
front-matter already set, it
is possible that those values exist as single string values instead of
lists.
If so, you can use an author.html
Hugo partial1 like below to
parse the author
parameter correctly, whether it’s a plain string or
a slice (list) of strings.
{{ with .Params.author }}
<span class="author">—
{{ if (reflect.IsSlice .) }}
{{ delimit . ", " }}
{{ else }}
{{ . }}
{{ end }}
</span>
{{ end }}
Forcing author
to be a string (alternative 1) #
If you are not comfortable with Hugo templates, you can alternatively
force the author
param to be a plain string instead of a list,
by setting it as a custom front-matter parameter:
#+author:
#+hugo_custom_front_matter: :author "FirstName LastName"
- Note
- Remember to set the default author name to nil if doing this,
by setting the
#+author
keyword (or:EXPORT_AUTHOR:
property) to nothing.
Exporting the list of authors to authors
front-matter instead of author
(alternative 2) #
If your theme supports parsing a list of authors from an authors
front-matter parameter (instead of author
), use the
#+hugo_front_matter_key_replace
feature as shown here.
-
You can find the same (or similar)
author.html
partial used in the Hugo theme used for this doc site. ↩︎