Separate content from structure for areas you might want to update from time to time — this time using data files.
Pulling content out of the layout into a data file
Iterating over a data file
There are several areas in the layout where we might want to update the content from time to time. For example, the social links, phone number, and the support email address. We can separate content from structure in a similar way we did for the navigation, only this time we’ll use data files.
A data file is a YAML, TOML, or JSON file on your Hugo site that acts like a read-only database. In this case, we’re going to create a data file for all the layout content we might want to update in the future.
/hugo_src/data/company.yml with the following content:
/hugo_src/layout/_default/baseof.html and change all of this hardcoded content in the header and footer to pull from the data file instead.
For example, the Facebook link will change to:
And the support phone too: