yamlquarto

How to change default titles on a .qmd document?


I am composing a report in Spanish using Quarto (a .qmd document intended for publication as HTML) in Rstudio. When preparing the YAML, I include the following:

---
title: "Avance de proyecto - 2025"
subtitle: "Presentación y análisis de los resultados preliminares"
author:
  - name: "Pedro Páramo"
    affiliation: "Universidad Rulfo"
    roles:
      - "Investigador Asociado"
lang: es
---

And the rendered HTML produces the attached image. I want to change the 'Autor/A' default title in Spanish to: 'Por:' ("by", in English) and 'Afiliación' to "Institución" and include the role of the author. Can anyone help me? I've tried creating a _locale/es.yml file, adding more code to the .qmd YAML, and several other approaches, but nothing has worked.

enter image description here


Solution

  • Author and affiliation can be translated directly via the language key:

    language: 
      title-block-author-single: "Por"
      title-block-affiliation-single: "Institución"
    

    Including the role requires on the other hand more work. You can use template-partials and modify title-metadata.html where the relevant part is

    $for(by-author)$
    <div>
      <div class="quarto-title-meta-heading">$language.title-block-role-single$</div>
      <div class="quarto-title-meta-contents">
        $for(by-author.roles)$
        <p class="role">
          $it.role$
        </p>
        $endfor$
      </div>
    </div>
    $endfor$
    

    It adds the role with a heading defined in language by

    language: 
      title-block-role-single: "Papel"
    

    where

    author:
      - name: "Pedro Páramo"
        affiliation: "Universidad Rulfo"
        roles:
          - "Investigador Asociado"
    

    enter image description here

    index.qmd

    ---
    title: "Avance de proyecto - 2025"
    subtitle: "Presentación y análisis de los resultados preliminares"
    author:
      - name: "Pedro Páramo"
        affiliation: "Universidad Rulfo"
        roles:
          - "Investigador Asociado"
    lang: es
    language: 
      title-block-author-single: "Por"
      title-block-affiliation-single: "Institución"
      title-block-role-single: "Papel"
    template-partials:
      - title-metadata.html
    ---
    

    title-metadata.html

    <div class="quarto-title-meta-container">
      <div class="quarto-title-meta-column-start">
        $if(by-affiliation/first)$
        <div class="quarto-title-meta-author">
          <div class="quarto-title-meta-heading">$labels.authors$</div>
          <div class="quarto-title-meta-heading">$labels.affiliations$</div>
          
          $for(by-author)$
          <div class="quarto-title-meta-contents">
            <p class="author">$_title-meta-author.html()$</p>
          </div>
          $if(by-author.affiliations)$
          <div class="quarto-title-meta-contents">
            $for(by-author.affiliations)$
            <p class="affiliation">
              $if(it.url)$
              <a href="$it.url$">
              $endif$
              $it.name$
              $if(it.url)$
              </a>
              $endif$
            </p>
            $endfor$
          </div>
          $endif$
          $endfor$
        </div>
        $endif$
    
        <div class="quarto-title-meta">
    
          $if(by-affiliation)$
          $elseif(by-author)$
          <div>
            <div class="quarto-title-meta-heading">$labels.authors$</div>
            <div class="quarto-title-meta-contents">
              $for(by-author)$
              <p>$_title-meta-author.html()$</p>
              $endfor$
            </div>
          </div>
          $endif$
          
          $if(date)$
          <div>
            <div class="quarto-title-meta-heading">$labels.published$</div>
            <div class="quarto-title-meta-contents">
              <p class="date">$date$</p>
            </div>
          </div>
          $endif$
    
          $if(date-modified)$
          <div>
            <div class="quarto-title-meta-heading">$labels.modified$</div>
            <div class="quarto-title-meta-contents">
              <p class="date-modified">$date-modified$</p>
            </div>
          </div>
          $endif$
          
          $if(doi)$
          <div>
            <div class="quarto-title-meta-heading">$labels.doi$</div>
            <div class="quarto-title-meta-contents">
              <p class="doi">
                <a href="https://doi.org/$doi$">$doi$</a>
              </p>
            </div>
          </div>
          $endif$
        </div>
      </div>
      <div class="quarto-title-meta-column-end quarto-other-formats-target">
      </div>
    </div>
    
    $if(abstract)$
    <div>
      <div class="abstract">
        <div class="block-title">$labels.abstract$</div>
        $abstract$
      </div>
    </div>
    $endif$
    
    $if(keywords)$
    <div>
      <div class="keywords">
        <div class="block-title">$labels.keywords$</div>
        <p>$for(keywords)$$it$$sep$, $endfor$</p>
      </div>
    </div>
    $endif$
    
    $for(by-author)$
    <div>
      <div class="quarto-title-meta-heading">$language.title-block-role-single$</div>
      <div class="quarto-title-meta-contents">
        $for(by-author.roles)$
        <p class="role">
          $it.role$
        </p>
        $endfor$
      </div>
    </div>
    $endfor$
    
    <div class="quarto-other-links-text-target">
    </div>