Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brand: logo paths are resolved incorrectly for documents in sub directories #11982

Open
gadenbuie opened this issue Jan 29, 2025 · 6 comments
Open
Assignees
Labels
brand `_brand.yml` bug Something isn't working triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone.
Milestone

Comments

@gadenbuie
Copy link
Collaborator

gadenbuie commented Jan 29, 2025

Bug description

Originally posted in posit-dev/brand-yml#66 (comment) by @szimmer:

I have an images folder in the root of a quarto site project. I then wanted to have subdirectories and some .qmd files in those subdirectories. When I do this, the icons work on the site but not on files in the subdirectory. I made a fairly small example.

It would be ideal if branding worked in all directories.

Steps to reproduce

See https://github.com/szimmer/try-quarto-brand, which contains a _brand.yml file with (essentially)

logo:
  small: images/favicon.png
  medium: images/favicon.png

a _quarto.yml

project:
  type: website

website:
  title: "tmpsite"
  navbar:
    left:
      - href: index.qmd
        text: Home
      - about.qmd

format:
  html:
    theme:
      - cosmo
      - brand
    css: styles.css
    toc: true

and two slides files

* slides.qmd
* slides/slides.qmd

Both slide files are identical

---
title: "Untitled"
format: revealjs
---

## Here's a slide

Expected behavior

Both slides, when rendered, should show the logo in the slides.

Actual behavior

Only the slides.qmd has the logo, slides/slides.qmd has a broken image.

Your environment

Quarto check output

quarto v1.6.40

@gadenbuie gadenbuie added the bug Something isn't working label Jan 29, 2025
@gadenbuie gadenbuie marked this as a duplicate of posit-dev/brand-yml#66 Jan 29, 2025
@mcanouil
Copy link
Collaborator

mcanouil commented Jan 29, 2025

What about adding a leading / as Quarto uses this to tell it's from the root of the project?

Edit: following Quarto's convention on paths

Screen.Recording.2025-01-29.at.16.38.14.mov

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 29, 2025

Side note, the following content in _brand.yml makes Quarto (main) crash but I was expected this with keys that have no values.

defaults:
  bootstrap:
    # bootstrap variable definitions
  quarto:
    format:
      # basic format-specific settings
      html:
      revealjs:
  shiny:
    # shiny specific settings
ERROR: Brand validation failed for /Users/mcanouil/Projects/misc/try-quarto-brand/_brand.yml.

In file _brand.yml
(line 56, columns 5--37) Field "bootstrap" has value # bootstrap variable definitions, which must instead be an object
55:   bootstrap:
56:     # bootstrap variable definitions
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57:   quarto:
✖ The value # bootstrap variable definitions is of type a null value.
ℹ The error happened in location defaults:bootstrap.


Stack trace:

In file _brand.yml
(line 56, columns 5--37) Field "bootstrap" has value # bootstrap variable definitions, which must instead be an object
55:   bootstrap:
56:     # bootstrap variable definitions
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57:   quarto:
✖ The value # bootstrap variable definitions is of type a null value.
ℹ The error happened in location defaults:bootstrap.

    at readAndValidateYamlFromFile (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/core/schema/validated-yaml.ts:51:11)
    at async projectResolveBrand (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/project/project-shared.ts:536:21)
    at async websiteNavigationConfig (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/project/types/website/website-shared.ts:167:24)
    at async initWebsiteNavigation (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/project/types/website/website-navigation.ts:167:7)
    at async Object.preRender (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/project/types/website/website.ts:120:5)
    at async renderProject (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/project.ts:397:5)
    at async Command.actionHandler (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/cmd.ts:248:26)
    at async Command.execute (https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1948:7)
    at async Command.parseCommand (https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1780:14)
    at async quarto (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/quarto.ts:190:5)

@mcanouil mcanouil added the brand `_brand.yml` label Jan 29, 2025
@mcanouil
Copy link
Collaborator

The trick question now is: does all tools using _brand.yml will read a leading / the same way?
Or should Quarto maybe prepend / in _brand.yml paths when appropriate? @gadenbuie @cscheid

@gadenbuie
Copy link
Collaborator Author

The trick question now is: does all tools using _brand.yml will read a leading / the same way?

No, in Python and R, paths inside _brand.yml are intended to be relative to the _brand.yml file. This is important outside of Quarto because _brand.yml files can be in subdirectories and are intended to be portable.

If Quarto wants to keep the leading /, it should only work inside _quarto.yml or places where brand is provided directly. Paths inside _brand.yml (or by any other name) should be relative to the brand.yml file.

@mcanouil mcanouil added enhancement New feature or request triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. and removed bug Something isn't working labels Jan 29, 2025
@cscheid
Copy link
Collaborator

cscheid commented Jan 29, 2025

This is a bug. Relative paths should be resolved relative to the path of the file defining the paths.

@cscheid cscheid added bug Something isn't working and removed enhancement New feature or request labels Jan 29, 2025
@cscheid cscheid added this to the v1.7 milestone Jan 29, 2025
@mcanouil
Copy link
Collaborator

mcanouil commented Jan 29, 2025

This is a bug. Relative paths should be resolved relative to the path of the file.

I'm confused. Relative to Which file?
I'm guessing you mean relative to _brand.yml.
Because currently the paths are resolved as relative to input/output files (qmd/html) and that's the issue.

Image

For completeness, it's not only abut slides not picking up the logo, but anything using the logo such as the "brand" shortcode ({{< brand logo header >}}) anywhere but at the root of the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brand `_brand.yml` bug Something isn't working triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone.
Projects
None yet
Development

No branches or pull requests

3 participants