quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.96k stars 327 forks source link

Conditional metada for different profiles on a website #4516

Open iuryt opened 1 year ago

iuryt commented 1 year ago

Discussed in https://github.com/quarto-dev/quarto-cli/discussions/4455

Originally posted by **iuryt** February 21, 2023 Hi, I am trying to write a multilingual web blog using Quarto. I think this software is amazing, but I am having trouble in defining different titles and categories for the blog posts depending on the language. I am using Quarto 1.2.1 CLI. The post is ```markdown --- title: Trying Quarto categories: News author: "Iury Simoes-Sousa" date: "2023-02-20" --- ::: {.content-visible when-profile="english"} This is the first post in a Quarto blog. Welcome! ![](https://quarto.org/quarto.png) I plan to post here my thoughts about Science, Technology and Music. ::: ::: {.content-visible when-profile="portuguese"} Este é o meu primeiro post no meu blog usando Quarto. Seja bem vindo! ![](https://quarto.org/quarto.png) Eu pretendo postar aqui as minhas idéias e tutoriais sobre ciência, tecnologia e música. ::: ``` which returns the following for english ![image](https://user-images.githubusercontent.com/5797727/220523193-06bbe5c3-832c-485e-81c2-e25cbbc4b25f.png) and the blog page is ```markdown --- title: "My Blog" listing: contents: posts sort: "date desc" type: default categories: true sort-ui: false filter-ui: false page-layout: full title-block-banner: true --- ``` ![image](https://user-images.githubusercontent.com/5797727/220523318-642c1557-942b-4506-8fbe-4bd26fb89d0d.png) Well, if I use what is suggested in #2822 The post will be: ```markdown --- title: | ::: {.content-visible when-profile="english"} Trying Quarto ::: ::: {.content-visible when-profile="portuguese"} Testando o Quarto ::: categories: News author: "Iury Simoes-Sousa" date: "2023-02-20" --- ::: {.content-visible when-profile="english"} This is the first post in a Quarto blog. Welcome! ![](https://quarto.org/quarto.png) I plan to post here my thoughts about Science, Technology and Music. ::: ::: {.content-visible when-profile="portuguese"} Este é o meu primeiro post no meu blog usando Quarto. Seja bem vindo! ![](https://quarto.org/quarto.png) Eu pretendo postar aqui as minhas idéias e tutoriais sobre ciência, tecnologia e música. ::: ``` Which returns the following for english: ![image](https://user-images.githubusercontent.com/5797727/220522430-709f80bf-ea2d-4270-bf35-9cc863ec6a74.png) and it messes up with the Blog page ![image](https://user-images.githubusercontent.com/5797727/220522657-221924de-8cfc-4a17-902b-d202b3fbeac1.png)
cscheid commented 1 year ago

Thanks for the feedback! We would like to do better in this situation, but the combination of conditional blocks and metadata is hard for us to support in general, because of a variety of technical issues on the order in which those are processed by us and Pandoc.

I think that it won't be easy to change the title of a post with profiles, unfortunately. I'll keep this open if other folks can find workarounds.

iuryt commented 1 year ago

Thanks for the feedback! We would like to do better in this situation, but the combination of conditional blocks and metadata is hard for us to support in general, because of a variety of technical issues on the order in which those are processed by us and Pandoc.

I think that it won't be easy to change the title of a post with profiles, unfortunately. I'll keep this open if other folks can find workarounds.

I see.. so for now, there is no workaround to this problem? I understand that in the current version, I cannot add conditional yaml metadata, but do you have any idea how I could have a similar result in a different way?

aito123 commented 1 year ago

Hi, this was just what I wanted to ask. I wanted to take advantage of quarto profiles to write a bilingual blog both spanish and english and all seems to work fine, but the YAML metadata is hard to condition based on the quarto profile. I would also be looking forward to this enhancement.