assets in docs deleted when distill site is built

I am hosting my distill site on Github pages.

Your GitHub Pages site is currently being built from the /docs folder in the main branch.

Where should I store assets that are not part of the distill site that I still want to make available on the domain? For instance, the main site is at http://research.nivi.io/. This serves up the distill blog.

Within docs I created decks/covid-vh-ke which serves up http://research.nivi.io/decks/covid-vh-ke/nov2020.html.

Every time I build the distill site, distill does what it's supposed to do and overwrites docs.

Where should I store things like this deck that I want to host on the same domain but are not part of the distill site? Is this even possible?

Hi,

distill website should be working like classic Rmarkdown website. That means, every file in the project working directory will be copied into the _site directory (or which name you configure in output_dir, I believe docs in your case.

That means you can have those other files living right up in your project directory and they all will be copied into the output dir. (except hidden files, files beginning with _, and files known to have source code (.R, .Rmd, ...).

That means if you put decks/covid-vh-ke right in the root project, when building the website it will be copied into the docs directory.

This is mention in distill doc https://rstudio.github.io/distill/website.html#site-output but also in Rmarkdown website doc https://bookdown.org/yihui/rmarkdown/rmarkdown-site.html#site-configuration
You'll see you can customize the default behavior using includeand / or exclude in _site.yml

Hope it helps

1 Like

Thanks, @cderv. This is helpful.

Here's what it looks like now:

root
  - _posts
    - 2020-12-04-tracking-vaccine-hesitancy
      - tracking-vaccine-hesitancy.Rmd
  - docs
  - decks
    - covid-vh-ke
      - nov2020.html

This might need to be a new question, but I'll start here because the root problem (get it?) is my confusion about file paths for distill/rmarkdown websites.

I'm trying to embed nov2020.html into tracking-vaccine-hesitancy.Rmd using xaringanExtra::share_again as @apreshill suggested when she looked at my post.

I tried going two levels up and then down into decks...

```{r embed-xaringan, echo=FALSE}
xaringanExtra::embed_xaringan(url = "../../covid-vh-ke/nov2020.html", ratio = "4:3")
```

but I get the error:

/rmd_output/3/covid-vh-ke/nov2020.html not found

I'm missing something about how the relative file structure.

Hi @ericpgreen,

In case it is helpful, here is where I did it:

But also, this is the index.Rmd, not a post, so not entirely sure. I also added this line to my _site.yml, but confess to not testing whether that is required or not for this to work:

1 Like

Yes you need to use the path to the slide decks as it will be copied into the side dir.
This should work when you'll build the website (I'll try to confirm with a small test on my side)

```{r embed-xaringan, echo=FALSE}
xaringanExtra::embed_xaringan(url = "decks/covid-vh-ke/nov2020.html", ratio = "4:3")
```

You can also add the include in YAML but that is not necessary.

1 Like

Yeah that only works for Rmd post on the root dir, like index.Rmd for @apreshill

:thinking:

Thanks for troubleshooting, @apreshill and @cderv. I have the same emoji face.

To be complete, I tried...

```{r embed-xaringan, echo=FALSE}
xaringanExtra::embed_xaringan(url = "decks/covid-vh-ke/nov2020.html", ratio = "4:3")
```

...and I confirmed that decks/ gets copied to docs when I build the site. But file not found.

Here's what the file structure looks like now:

root
  - _posts
    - 2020-12-04-tracking-vaccine-hesitancy
      - tracking-vaccine-hesitancy.Rmd
  - docs
    - posts
      - 2020-12-04-tracking-vaccine-hesitancy
        - index.html
    - decks
      - covid-vh-ke
        - nov2020.html
  - decks
    - covid-vh-ke
      - nov2020.html

I also tried going up 2 levels, but no luck:

```{r embed-xaringan, echo=FALSE}
xaringanExtra::embed_xaringan(url = "../..decks/covid-vh-ke/nov2020.html", ratio = "4:3")
```

Actually, good news. The last idea works, I just forgot a /:

```{r embed-xaringan, echo=FALSE}
xaringanExtra::embed_xaringan(url = "../../decks/covid-vh-ke/nov2020.html", ratio = "4:3")
```
1 Like

Great !

This is indeed something related to path. See about absolute path and relative path in

I believe using an absolute path would work, when the site is served (not previewed in RStudio viewer)
I forgot the / in my previous answer

```{r embed-xaringan, echo=FALSE}
xaringanExtra::embed_xaringan(url = "/decks/covid-vh-ke/nov2020.html", ratio = "4:3")
```

This would work online where your site is hosted and locally when using a web server. Example by running :

servr::httd("_site")
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.