Skip to content

quarto preview unexpected non-idempotent behavior #4469

Open

Description

@MattF-NSIDC

Bug description

Hello all, I'm a new Quarto user and have been having a great time. Thank you ❤️

I'm using Quarto 1.2.335 via conda-forge on Ubuntu 20 LTS. I'm not using the RStudio IDE, just editing with vi.

I've been building a presentation which consists of several revealjs slide decks, and I want those to render to GH Pages, and that's working great. However, since I have multiple slide decks, I also want to render an HTML index page which includes links to all the slide decks. This seems to render correctly, but does not preview as expected; on the first run the slides appear as an HTML page using the "cosmo" theme instead of a revealJS presentation. Only after a hot-reload or re-run of the preview command do the slides appear as slides.

I was not able to make a reproducible example in a single QMD file, but my process to reproduce this issue was:

  1. Create project template
    quarto create-project sscce-quarto-slides-in-website --type website
    
  2. Create slides/index.qmd with format: 'revealjs' in front-matter
  3. Add link from index.qmd to slides/index.qmd
  4. quarto preview index.qmd
  5. Click the link to view the slides, and it will display as an HTML page, not a RevealJS presentation
  6. CTRL+C on the preview process, and run it again.
  7. Click the link to view the slides, and it will display as a RevealJS presentation
  8. Delete the .quarto and _site directories, do a preview, and the slides will again display as a HTML page, not a RevealJS presentation

I've created a repository with the project state that reproduces the issue, and the details of the issue in README.md: https://github.com/MattF-NSIDC/sscce-quarto-slides-in-website

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.

Activity

  1. added
    bug
    on Feb 22, 2023
  2. cscheid commented on Feb 22, 2023

    @cscheid
    Member

    Thanks for the report! Any chance you can try this with our 1.3 prerelease versions as well?

  3. MattF-NSIDC commented on Feb 23, 2023

    @MattF-NSIDC
    Author

    I will try this. I have only installed Quarto using conda before now, so it may take me a minute :)

  4. MattF-NSIDC commented on Feb 23, 2023

    @MattF-NSIDC
    Author

    That was quick and easy, thank you :) I installed the Ubuntu distribution quarto-1.3.217-linux-amd64.deb and the behavior is the same as in the original report: I get different results after running preview twice. On 1st preview I get an HTML page for my slide deck (unexpected), and on 2nd preview (IFF I leave the _site and .quarto dirs in-place) I get a RevealJS presentation that works exactly the way I expect.

  5. cscheid commented on Feb 23, 2023

    @cscheid
    Member

    This is ultimately the same problem as we discussed on the other issue, right?

  6. MattF-NSIDC commented on Feb 23, 2023

    @MattF-NSIDC
    Author

    It looks to me like this is a similar issue to #4470 , but I think not the same user error and not the same solution: I'm still seeing this problem after applying the solution we discussed to #4470 .

    I think the issue is: when running preview, slides/index.html is rendered both with revealjs format (because it's specified in front-matter or _metadata.yml) and html format (because it's specified in _quarto.yml). The output filename is the same for both, so only one can exist after the render. I don't understand why the file that "wins" is different on first or second preview. Race condition?

    Is there a way I can tell Quarto not to render the content in slides/ as html and only render as revealjs format so the "clobbering" can't happen?

  7. MattF-NSIDC commented on Feb 23, 2023

    @MattF-NSIDC
    Author

    I tried to hack my way to my desired outcome by editing slides/_metadata.yml to make the undesired output have a non-conflicting filename, but that had similar issues with link-generation (my link to slides/index.qmd now points to the plain HTML output, not the slide, and with the wrong filename slides/index.plain.html.plain.html):

    format:
      html:
        output-ext: 'plain.html'
      revealjs:
        toc: true
    
  8. cscheid commented on Feb 23, 2023

    @cscheid
    Member

    I expected that metadata merging of the format to be smart in that it should be setting the format rather than adding a new one (this is special behavior for format). You can see this behavior in action by setting

    format: 
      pdf: default
    

    on test.qmd in a new website, and note how we don't build test.html and test.pdf files. I wonder if this is a bug with _metadata.yml specifically.

  9. cscheid commented on Feb 23, 2023

    @cscheid
    Member

    I'm now having a hard time reproducing your issue.

    I've created a barebones quarto website project, then created a subdirectory called "slides" with two files:

    slides/_metadata.yml

    format:
      revealjs: default

    slides/file.qmd

    ## Hello
    
    How will this render?

    All of these show a revealjs file:

    • quarto preview slides/file.qmd,
    • quarto preview (and then navigating to slides/file.html)
    • quarto render slides/file.qmd (and then inspecting the result)
  10. MattF-NSIDC commented on Feb 23, 2023

    @MattF-NSIDC
    Author

    I followed those steps and quarto preview behaves exactly as expected (thank you!), but quarto preview index.qmd reproduces this issue.

    Does the issue reproduce for you if you do quarto preview index.qmd?

    I got into the habit of explicitly specifying a file to preview when I was working on my slides project (also my first Quarto project), because I didn't have an index file initially. Is the behavior of preview supposed to be different between these two invocation styles?

  11. MattF-NSIDC commented on Feb 23, 2023

    @MattF-NSIDC
    Author

    Forgot to specify: before running quarto preview index.qmd, please delete _site, .quarto, and site_libs (if present), and I think the issue should reproduce on first run, but not reproduce on second run.

  12. cscheid commented on Feb 23, 2023

    @cscheid
    Member

    I can totally repro that, and it's a bug! Thanks.

  13. MattF-NSIDC commented on Feb 23, 2023

    @MattF-NSIDC
    Author

    @cscheid Thank you! I think I'm noticing another aspect to this issue.

    • Start with your example setup from a few posts up
    • Use quarto preview (no [file] argument), and load up the slide file
    • Edit index.html and save
    • The slide will hot-reload as plain HTML, not RevealJS
  14. cscheid commented on Feb 23, 2023

    @cscheid
    Member

    @jjallaire @dragonstyle

    This is an interesting one. Here's the full story:

    $ quarto create
     ? Create › project
     ? Type › website
     ? Directory › repro
    Creating project at /Users/cscheid/Desktop/daily-log/2023/02/22/repro:
      - Created _quarto.yml
      - Created index.qmd
      - Created about.qmd
      - Created styles.css
     ? Open With › (don't open)
    $ md repro/slides
    $ echo "format:\n  revealjs: default" > repro/slides/_metadata.yml
    $ echo "## Hello\n\nSlides or not?" > repro/slides/file.qmd
    $ echo "\n\n[slides](slides/file.qmd)" >> repro/index.qmd
    $ cd repro
    $ quarto preview index.qmd
    

    Now click on the "slides" link, and this will show an html render, not a revealjs render.

    however, if you repeat the whole thing, and type quarto preview instead of quarto preview index.qmd, slides/file.html renders correctly as revealjs (!?)

  15. MattF-NSIDC commented on Feb 23, 2023

    @MattF-NSIDC
    Author

    I noticed another weird thing!!!

    however, if you repeat the whole thing, and type quarto preview instead of quarto preview index.qmd, slides/file.html renders correctly as revealjs (!?)

    Once you have file.html rendering correctly as revealjs using quarto preview, trigger a hot reload by editing index.qmd and it will no longer render correctly. Trigger another hot reload by editing slides/file.qmd and it will be back to rendering correctly as revealjs. It seems to matter which file triggers the hot reload.

    Thank you so much for your help today. It's been extremely valuable. ❤️ Quarto & team! :)

  16. added this to the v1.3 milestone on Feb 23, 2023
  17. cscheid commented on Feb 24, 2023

    @cscheid
    Member

    (Note to yourselves, serveProject is getting to: html somehow and that overrides things)

  18. self-assigned this
    on Feb 24, 2023
  19. jjallaire commented on Feb 26, 2023

    @jjallaire
    Collaborator

    This occurs b/c we pin the preview format here:

    https://github.com/quarto-dev/quarto-cli/blob/main/src/command/preview/cmd.ts#L267

    I don't however think we should fix this right now because I don't fully recall what the purpose of that line of code is (it could easily be e.g. to facilitate proper switching between HTML and PDF formats for books). Further, I think part of the reason we put this in is that the preview server actually runs in different modes (presentation vs. non-presentation) and we actually want it to restart itself when a presentation is previewed. Again, it might be fine to remove that line of code or it might not be fine (requires more experimentation).

    One note is that if you just render the slides once then they will indeed show up correctly as slides. This problem is restricted to a fresh preview of a site that hasn't been previously rendered.

    Going to move this to v1.4 so we can take a closer look when we are less pressed for time.

  20. modified the milestones: v1.3, v1.4 on Feb 26, 2023
  21. mfisher87 commented on Feb 27, 2023

    @mfisher87

    the preview server actually runs in different modes (presentation vs. non-presentation)

    Interesting! what's the difference between presentation mode and non?

    One note is that if you just render the slides once then they will indeed show up correctly as slides. This problem is restricted to a fresh preview of a site that hasn't been previously rendered.

    FWIW, it also re-occurs if you trigger a hot reload by editing a non-slide file.

  22. modified the milestones: v1.4, v1.5 on Nov 28, 2023
  23. modified the milestones: v1.5, Future on Feb 12, 2024
  24. added
    preview
    on Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugpreview

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions