I have some data files to be reused in several pages and languages via different shortcodes. Should I stuff the files in the data directory or assets directory? What is the difference?
If the data files are used infrequently, or if they are CSV files, place them in the assets directory. Otherwise place them in the data directory. My understanding is that we read the contents of the data directory into memory for the entire build.
They are JSON files. I find that format easier to read.
I guess the data directory will work because I saw the data can also be grouped by language.
Yes, but the language selection isnβt automatic. Youβll need to do something like this:
{{ index .Site.Data .Language.Name "foo" }}
The corresponding directory structure for an en + de siteβ¦
data/
βββ de/
β βββ foo.yaml
βββ en/
βββ foo.yaml
1 Like
{{ index .Site.Data .Language.Lang }} that syntax works too.