Multilingual only for data folder

Hi, I’m trying to add a multilingual functionality to my website for French and Spanish (on top of English). However, I have 2 issues/questions:

  • How can I have the data folder to behave the same way as content by filename. I would like to have team.en.yml, team.fr.yml and team.es.yml but in the documentation, it only mentions the content folder.
  • In the content folder, I would like to show all blog posts irrelevant of the languages (at least for now, since I don’t have enough content for fr and es).

I’m basically only interested in translating the information part of the website (about us, services, team…) but not the blog part.
Thanks a lot for your help.

The data folder is language agnostic, but you can do something ala:

{{ $mydata := (index .Site.Data .Site.Language.Lang) }}

The above would need a /data/fr, i.e. a folder per language.

I’ve done it using a variation of what @bep suggest (in action here: https://moodlebox.net). See e.g. my carousel partial:


And the structure of the corresponding data folder:

Thanks a lot, that was really helpful. I thought I made an error in the config files while I actually made a stupid error in the layout, I was putting {{ $mydata := (index .Site.Data .Site.Language.Lang) }} above and not below the safeHTML.

problem is fixed - i made a mistake in defining the variable… :sweat_smile:


Hi there

I have a similar problem, do not understand how I can apply the above solution to my project.

All page contents except the title are in /data/ - the creator of my template left the _index.md in Content quite empty.

i don’t really understand what exactly i have to enter, because unlike in the example, not only a block is fetched but part of the path has to be changed; data.en.homepage.banner for example - how can i fill only the en in it with the current language selection?

{{ with .Site.Data.homepage.banner }}  
  <section class="hero-section bg-cover position-relative overlay" style="background-image: url('{{ .bgImage | absURL }}');">
    <div class="hero-content">
      <div class="container">
        <div class="row">
          <div class="col-md-10 mx-auto text-center">
            <h1 class="text-white mb-5 text-capitalize">{{ .title | markdownify }}</h1>
            <h2 class="text-light mb-4 mx-lg-5 px-lg-5 content">{{ .content | markdownify }}</h2>
            {{ if .button1.enable }}
            {{ with .button1 }}
            <a href="{{ .link | absURL }}" class="btn btn-outline-primary m-2">{{ .label }}</a>

the corresponding data / yml file contains the title, content, button1’s properies.

Someone an idea how to fix that?