rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.73k stars 334 forks source link

Detect multilingual exampleSites #537

Closed apreshill closed 3 years ago

apreshill commented 3 years ago

When I start a new site with a multilingual theme, the sample R Markdown post always ends up in the wrong place, see:

https://github.com/apreshill/introduce-yourself/tree/master/content https://github.com/apreshill/zzo/tree/master/content

Perhaps we could detect the combo of defaultContentLanguage and defaultContentLanguageInSubdir keys in the YAML?

https://gohugo.io/content-management/multilingual/#configure-languages

defaultContentLanguage: en
defaultContentLanguageInSubdir: yes

https://github.com/apreshill/zzo/blob/bff76d2d4e5ed5ea07e76f2f770aab06f9a6b469/config.yaml#L4-L5

Checklist

When filing a feature request, please check the boxes below to confirm that you have provided us with the information we need. Have you:

cderv commented 3 years ago

This comes from new_site() with sample = TRUE. It currently assumes that the website organization will be first

content/
  \-- blog/
     \-- ...

or

content/
  \-- post/
     \-- ...

and if he does not exist it will create the latter.

https://github.com/rstudio/blogdown/blob/b860d27fb475eeb7401fbc0542d46962eeac17b7/R/hugo.R#L163-L172

For international website, it will always create the sample at the root and not in folder.

I believe the key to detect would be languages first, and if defaultContentLanguage is set with defaultContentLanguageInSubdir = TRUE then, put the post in default language folder. Other is the two latter keys are not defined, defaultContentLanguage will be en by default, not under a subdir by default.

yihui commented 3 years ago

Should be fixed now. Thanks for the report!