Creating a Listing Page equivalent in a Distill website.


I'm creating a Distill website to serve as an online "textbook" with topic chapters. It currently has one "docs" folder (and one "images" folder) for the website content. It's version-controlled via Github.

I would like to create a page that would be the (aesthetic) equivalent of a Listing Page (example below) for a Distill blog that has the same format: an excerpt of the chapter introduction with a (preview) image alongside. I could manually update this page as I add chapters.

I'd appreciate ideas about how I might achieve this.



Hi @howardm19. If I got your question right, you are looking for a way to automate the creation of the page. I write a function that read your list directories under a subdir of _post and create a yaml file serves as a new listing page. Every time you update any chapters in the folder, you should just run the function and it will recreate the file. Here is the code:

create_new_listing <- function(title = "My title", subfolder = "Gallery"){
override <- T
if(file.exists(here::here(paste0(subfolder, ".Rmd")))){
  usethis::ui_info("File exists, override?")
  override <- utils::menu(choices = c("Yes", "No")) == 1
write_yml <- function(what){
    write(what, file = here::here(glue::glue("{subfolder}.Rmd")), append = TRUE)

file.create(here::here(paste0(subfolder, ".Rmd")))

write_yml(glue::glue("title: {title}"))
write_yml("site: distill::distill_website")
write_yml("  posts:")
  list.dirs(here::here(glue::glue("_posts/{subfolder}")), full.names = F, recursive = F),
  function(.x){ write_yml(paste0('   - ',subfolder, '/', .x)); cat('\n')}
} else {
  usethis::ui_oops("Your file has not been touched!")


I've just serendipitously realized that one can add a Blog function to an existent Distill web site. Here are the instructions:

Then one can create a Listing page for the Blog.

I think the excellent Distill documentation (Distill for R Markdown) should include this as a possibility.



This has been cross posted on GH also and answered there:

Custom collections can be created in distill

This topic was automatically closed 7 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.