Open mickeykawai opened 2 hours ago
You need to set site-url
to the root of your book as described in the documentation https://quarto.org/docs/websites/website-navigation.html#non-root-site-paths (it's also described in few other places such as https://quarto.org/docs/reference/projects/books.html)
If you don't set it, then the default is to take the root of the domain which of course will break your site/book if it is not at the root.
I tried two yml where I added site-url: <url>
as below but either does not work.
site-url: <url>
just below the book:
in yml.
mybook1
described as above. mybook3
and mybook4
contents are attached as Archive 2.zip
below. mybook3
where site-url: http://localhost:3000/mybook3
is added._quarto.yml
project:
type: book
book:
site-url: http://localhost:3000/mybook3
title: "mybook3"
author: "Norah Jones"
date: "10/19/2024"
chapters:
- index.qmd
- intro.qmd
- summary.qmd
- references.qmd
bibliography: references.bib
format:
html:
theme: cosmo
pdf:
documentclass: scrreprt
mybook4
where site-url: http://localhost:3000
is added._quarto.yml
project:
type: book
book:
site-url: http://localhost:3000
title: "mybook4"
author: "Norah Jones"
date: "10/19/2024"
chapters:
- index.qmd
- intro.qmd
- summary.qmd
- references.qmd
bibliography: references.bib
format:
html:
theme: cosmo
pdf:
documentclass: scrreprt
~/Sites % ls -lh
total 0
lrwxr-xr-x 1 mickey staff 57B Oct 19 17:46 mybook1 -> <working_dir>/mybook1/_book
lrwxr-xr-x@ 1 mickey staff 57B Oct 19 17:45 mybook2 -> <working_dir>/mybook2/_book
lrwxr-xr-x 1 mickey staff 57B Oct 19 18:38 mybook3 -> <working_dir>/mybook3/_book
lrwxr-xr-x 1 mickey staff 57B Oct 19 18:41 mybook4 -> <working_dir>/mybook4/_book
~/Sites %
I cannot reproduce. Note that your workflow is not really simple.
quarto create project book Issue-11115 Issue-11115
Modify _quarto.yml
:
project:
type: book
output-dir: ../docs/subfolder
book:
site-url: subfolder
title: "subfolder"
author: "Norah Jones"
date: "10/19/2024"
chapters:
- index.qmd
- intro.qmd
- summary.qmd
- references.qmd
bibliography: references.bib
format:
html:
theme: cosmo
pdf:
documentclass: scrreprt
quarto render
Repository: https://github.com/mcanouil/quarto-cli-11115
To me, the issue is in your workflow rather than in Quarto.
Bug description
Upon request by cderv at Posit Community (https://forum.posit.co/t/is-there-an-easy-way-or-option-to-host-multiple-rendered-html-quarto-books-under-a-single-local-web-server/186888/4), I re-post the issue here.
Bug:
Workaround:
<base href="...">
tag during Render HTML (e.g.<base href="http://localhost:3000/mybook2/">
.index.html
by hand to add the tag manually is enough.Steps to reproduce
mybook1
andmybook2
contents are uploaded asArchive.zip
below.Procedure:
mybook1
(where default QuartoBook behavior does not work)mybook1
(at any directory you like).index.qmd
mybook2
(where my script is added and_quarto.yml
is modified to includeproject: post-render:
before Render)mybook2
(at any directory you like).scripts/add-base.sh
in themybook2/
directory.add-base.sh
:Open
_quarto.yml
type: book
(l.2)quarto.yml
is now as follows.Open
index.qmd
Hit Render (Render HTML).
Difference between the original
index.html
and the one post-rendered.Soft link the two quarto books in html to
~/Sites/
(where you set up web server document root).Examine on browser.
http://localhost:3000
mybook1
andmybook2
.Archive.zip
Expected behavior
HTML is formatted correctly with JS search functionality working.
Actual behavior
HTML is not formatted correctly.
Your environment
Quarto check output