Skip to content

Page titles not placed correctly when using custom template partials in websites #13247

Closed

Description

@andrewheiss

I have:

  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide

Bug description

Just ran into an issue related to #11618 and #12980 and #11596 while updating some course websites, but I think the problem is different enough to warrant a separate issue.

Sometime around October 2024 with #11224, h1 title canonicalization (i.e. wrapping page titles in <header><h1>blah</h1></header>) was introduced, and it was a little too overeager when using a custom template. That was fixed with #11596, but issues remain when using template partials (rather than full templates) inside Quarto websites.

Steps to reproduce

With this index.qmd:

---
title: "I am a title"
format:
  html:
    template-partials:
      - title-block.html
---

Here's some text.

and this _quarto.yml:

project:
  type: website

website:
  title: "A neat website"

and this title-block.html template partial:

<div class="meta">
$if(title)$
  <h1>$title$</h1>
$endif$
</div>

Actual behavior

Currently (using Quarto 1.8.20, but it's been happening since Quarto 1.6ish), that content area renders like this:

<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block"><h1 class="title display-7">I am a title</h1></header>

<div class="meta">
  
</div>

<p>Here’s some text.</p>

</main>

with an empty .meta div and the canonicalized h1 by itself at the very beginning.

Expected behavior

Previously with Quarto 1.5, it would render to something like this—well, not exactly this; I don't have 1.5 installed anywhere, but the main point is that the h1 would appear inside the .meta div as defined in the template):

<div class="meta">
<h1 class="title display-7">I am a title</h1>  
</div>

<p>Here’s some text.</p>

You can see the changed behavior IRL by comparing the home page here from fall 2024 with here from fall 2025. That area with the page/course title and the hex logo uses a custom title-block.html template partial (here) to put the title in a bootstrap grid like this (grossly oversimplified):

<div class="grid">
    <div class="g-col-6">
        $if(title)$<h1 class="title">$title$</h1>$endif$
    </div>

    <div class="g-col-6">
        HEX LOGO
    </div>
</div>

But since Quarto 1.6, that title now renders outside of that whole .grid class, like this:

<header><h1>TITLE GOES HERE NOW</h1></header>
<div class="grid">
    <div class="g-col-6">
        <!-- Nothing is here! -->
    </div>

    <div class="g-col-6">
        HEX LOGO
    </div>
</div>

Your environment

  • IDE: Positron 2025.07.0 (Universal) build 204
  • OS: macOS Sequoia 15.6

Quarto check output

quarto check
Quarto 1.8.20
[✓] Checking environment information...
      Quarto cache location: /Users/andrew/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.6.3: OK
      Dart Sass version 1.87.0: OK
      Deno version 2.3.1: OK
      Typst version 0.13.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.8.20
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/andrew/Library/TinyTeX/bin/universal-darwin
      Version: 2025

[✓] Checking Chrome Headless....................OK
      Using: Chrome found on system
      Path: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
      Source: MacOS known location

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.13.1
      Path: /Users/andrew/.virtualenvs/quarto/bin/python3
      Jupyter: 5.7.2
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.5.0
      Path: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources
      LibPaths:
        - /Users/andrew/Library/R/arm64/4.5/library
        - /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
      knitr: 1.50
      rmarkdown: 2.29

[✓] Checking Knitr engine render......OK

Activity

  1. added
    bug
    on Aug 20, 2025
  2. andrewheiss commented on Aug 20, 2025

    @andrewheiss
    Author

    This might be a separate issue, but I'm pretty sure it's a symptom of the same phenomenon since it's directly related to template partials and the canonicalized h1

    Weird things also happen when using the code-tools button. With this index.qmd (and with the same _quarto.yml and title-block.html from above):

    ---
    title: "I am a title"
    format:
      html:
        code-tools: true
        template-partials:
          - title-block.html
    ---
    
    Here's some text.
    
    ```{r}
    1 + 1
    ```
    

    …the code tools button no longer appears on the same line as the title and instead appears above:

    Image

    The code tools button is placed immediately after the canonicalized <header> element, but that <h1></h1> element is actually empty(!) and the title appears in the .meta div as expected (which is WEIRD!):

    <!-- main -->
    <main class="content" id="quarto-document-content"><header id="title-block-header" class="quarto-title-block"><h1 class="title display-7"></h1></header><div class="quarto-title-block"><div class="quarto-title-tools-only"><button type="button" class="btn code-tools-button" id="quarto-code-tools-source"><i class="bi"></i> Code</button></div></div>
    
    <div class="meta">
      <h1>I am a title</h1>
    </div>
    
    
    <p>Here’s some text.</p>
    <div class="cell">
    <div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="dv">1</span> <span class="sc">+</span> <span class="dv">1</span></span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
    <div class="cell-output cell-output-stdout">
    <pre><code>[1] 2</code></pre>
    </div>
    </div>
    
    <!-- -->
    
    </main> <!-- /main -->
    

    The code tools button appears as expected when not using the custom template partial:

    ---
    title: "I am a title"
    format:
      html:
        code-tools: true
    ---
    
    Here's some text.
    
    ```{r}
    1 + 1
    ```
    
    Image
    <!-- main -->
    <main class="content" id="quarto-document-content">
    
    <header id="title-block-header" class="quarto-title-block default">
    <div class="quarto-title">
    <div class="quarto-title-block"><div><h1 class="title">I am a title</h1><button type="button" class="btn code-tools-button" id="quarto-code-tools-source"><i class="bi"></i> Code</button></div></div>
    </div>
    
    <div class="quarto-title-meta">
       
      </div>
    </header>
    
    <p>Here’s some text.</p>
    <div class="cell">
    <div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="dv">1</span> <span class="sc">+</span> <span class="dv">1</span></span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
    <div class="cell-output cell-output-stdout">
    <pre><code>[1] 2</code></pre>
    </div>
    </div>
    
    <!-- -->
    
    </main> <!-- /main -->
    

    For an IRL example, compare this from fall 2024 with this from fall 2025, using this template partial

    Image Image
  3. self-assigned this
    on Aug 20, 2025
  4. added this to the v1.9 milestone on Aug 20, 2025
  5. added
    websites
    on Aug 20, 2025
  6. andrewheiss commented on Jan 4, 2026

    @andrewheiss
    Author

    K, so this is actually no longer an issue (discovered in a separate but related issue at #13841 (comment)). The main problem is that I wasn't using all the special Quarto-specific elements in the custom title-block template partial—I was using the base pandoc title-block partial at src/resources/formats/html/pandoc/title-block.html instead of the Quarto template one at src/resources/formats/html/templates/title-block.html.

    With a barebones template partial, titles are canonicalized differently and the code-tools button is placed incorrectly because the resulting content is missing a lot of the Quarto-specific CSS scaffolding, etc. If adjustments are made based on the htm/templates version of the title-block.html partial, which includes all the expected CSS IDs and classes + the pandoc $title-metadata.html()$ template, things work as expected and everything is placed correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugwebsites

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions