Brash Equilibrium
Brash Equilibrium

Reputation: 1357

Trouble with title rendered in bookdown using bs4_book output type

I'm creating a course notebook here: https://github.com/hanowell/uwsoc533a

The title of the book is supposed to be "UW SOC/CS&SS 533 A Course Notes" as per the YAML frontmatter in the index.Rmd file, copied below:

--- 
title: "UW SOC/CS&SS 533 A Course Notes"
author: "Ben Hanowell"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
url: "https://hanowell.github.io/uwsoc533a/"
# cover-image: path to the social sharing image like images/cover.jpg
description: |
  These are the course notes for Research Methods in Demography, a course cross-listed as SOC/CS&SS 533 A at the University of Washington.
biblio-style: apalike
csl: chicago-fullnote-bibliography.csl
---

Yet when I bookdown::render_book() and then bookdown::serve_book (and also render the book on GitHub Pages), the title in the upper left corner is instead "Indirect estimation methods." You can see this is docs/index.html line 7, reproduced below:

<title>Welcome | Indirect estimation methods</title>

"Indirect estimation methods" happens to be the title of the 10th chapter of the book.

More recently, I have tested out deleting all but the first chapter, then having only two chapters, and it looks like whatever the last chapter is in the book has its title chosen as the title of the book. I tried again, adding a second chapter, and the title of that chapter was suddenly the title of the book in upper left corner of the book's page.

The output of xfun::session_info() is below:

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042), RStudio 1.4.1717

Locale:
  LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
  LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
  LC_TIME=English_United States.1252    

Package version:
  assertthat_0.2.1   base64enc_0.1.3    bookdown_0.24      brio_1.1.2         bslib_0.3.0.9000  
  cli_3.0.1          colorspace_2.0-2   compiler_4.1.0     crayon_1.4.1       DBI_1.1.1         
  digest_0.6.27      downlit_0.2.1      dplyr_1.0.7        ellipsis_0.3.2     evaluate_0.14     
  fansi_0.5.0        farver_2.1.0       fastmap_1.1.0      fs_1.5.0           generics_0.1.0    
  glue_1.4.2         graphics_4.1.0     grDevices_4.1.0    highr_0.9          htmltools_0.5.2   
  httpuv_1.6.2       jquerylib_0.1.4    jsonlite_1.7.2     knitr_1.33         labeling_0.4.2    
  later_1.3.0        lifecycle_1.0.0    magrittr_2.0.1     markdown_1.1       methods_4.1.0     
  mime_0.11          munsell_0.5.0      pillar_1.6.2       pkgconfig_2.0.3    promises_1.2.0.1  
  purrr_0.3.4        R6_2.5.1           rappdirs_0.3.3     RColorBrewer_1.1.2 Rcpp_1.0.7        
  rlang_0.4.11       rmarkdown_2.9      rstudioapi_0.13    sass_0.4.0         scales_1.1.1      
  servr_0.22         stats_4.1.0        stringi_1.7.4      stringr_1.4.0      tibble_3.1.3      
  tidyselect_1.1.1   tinytex_0.32       tools_4.1.0        utf8_1.2.2         utils_4.1.0       
  vctrs_0.3.8        viridisLite_0.4.0  xfun_0.24          xml2_1.3.2         yaml_2.2.1 

Upvotes: 1

Views: 181

Answers (1)

Brash Equilibrium
Brash Equilibrium

Reputation: 1357

The solution to this problem is rather embarrassing:

I was putting YAML frontmatter in the .Rmd files for the chapters, and specifying the title argument therein, which overwrites the title argument in index.Rmd.

Silly me.

Upvotes: 2

Related Questions