Data folder best practices

Hugo provides data file feature https://gohugo.io/extras/datafiles/

I have some question about usage and practices as theme developer. Today I’m developing theme https://github.com/kakawait/hugo-tranquilpeak-theme and this theme becomes more and more customizable, thus more and more configuration keys are created.

What do you think about data file for theme customization? For example, I allow user to customize date format

[params]
  dateFormat = "2 January 2006"

but I saw some theme developer uses data file to customize such information, see https://github.com/enten/hyde-y/blob/master/data/Formats.yaml

Other use case is to override copyright, by default my theme is displaying theme like following:

© 2016 Thibaud Leprêtre. All Rights Reserved

© {{ .Now.Format "2006" }} {{ .Site.author.name }}. {{ i18n "footer.copyright" }}

But someone request me to be able to add link associated to {{ .Site.author.name }} thus I created this param (that will be used if present or fallback to above version)

[params.footer]
  copyright = "<a href=\"#an-url\">Your Name</a>"

to allow customize © 2016 <CUSTOMIZATION>. All Rights Reserved.

How can I determine if it’s better to create config.toml param or data ? Do you think is good idea to add configuration and not direct content (data) inside data file?

Hello,

Have you managed to use data file or config.toml file and so why ?

I think I need hot reload, since config.toml isn’t hot-reloaded i guess i have to go with a “data/website_config/XXXX.json” parameter type of logic.

Anyone have advice that the data shouldn’t be used for config parameters?

  • Thanks