Bug Report: render bookdown::gitbook but the output filename is the first heading name.

Here is the reproducible example.

---
author: Jiaxiang Li
date: "`r Sys.Date()`"
output: bookdown::gitbook
---

# test_heading

xxx

I save the code into an Rmd file a20200720144508.Rmd, when I run rmarkdown::render, I get the output file named by test_heading.html instead of the default a20200720144508.html.

For the reproducible purpose, here is my session infomation.

"si"
#> [1] "si"

Created on 2020-07-20 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                         
#>  version  R version 3.6.0 (2019-04-26)  
#>  os       Windows 10 x64                
#>  system   x86_64, mingw32               
#>  ui       RTerm                         
#>  language (EN)                          
#>  collate  Chinese (Simplified)_China.936
#>  ctype    Chinese (Simplified)_China.936
#>  tz       Asia/Taipei                   
#>  date     2020-07-20                    
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version    date       lib source                        
#>  assertthat    0.2.1      2019-03-21 [2] CRAN (R 3.6.2)                
#>  backports     1.1.5      2019-10-02 [2] CRAN (R 3.6.1)                
#>  callr         3.2.0      2019-03-15 [2] CRAN (R 3.6.0)                
#>  cli           2.0.1      2020-01-08 [2] CRAN (R 3.6.2)                
#>  crayon        1.3.4      2017-09-16 [2] CRAN (R 3.6.0)                
#>  desc          1.2.0      2018-05-01 [2] CRAN (R 3.6.0)                
#>  devtools      2.1.0      2019-07-06 [2] CRAN (R 3.6.1)                
#>  digest        0.6.19     2019-05-20 [2] CRAN (R 3.6.0)                
#>  evaluate      0.14       2019-05-28 [2] CRAN (R 3.6.0)                
#>  fansi         0.4.0      2018-10-05 [2] CRAN (R 3.6.0)                
#>  fs            1.3.1      2019-05-06 [2] CRAN (R 3.6.0)                
#>  glue          1.3.1      2019-03-12 [2] CRAN (R 3.6.0)                
#>  highr         0.8        2019-03-20 [2] CRAN (R 3.6.0)                
#>  htmltools     0.4.0      2019-10-04 [2] CRAN (R 3.6.1)                
#>  knitr         1.27       2020-01-16 [2] CRAN (R 3.6.2)                
#>  magrittr      1.5        2014-11-22 [2] CRAN (R 3.6.1)                
#>  memoise       1.1.0      2017-04-21 [2] CRAN (R 3.6.1)                
#>  pkgbuild      1.0.3      2019-03-20 [2] CRAN (R 3.6.1)                
#>  pkgload       1.0.2      2018-10-29 [2] CRAN (R 3.6.1)                
#>  prettyunits   1.0.2      2015-07-13 [2] CRAN (R 3.6.0)                
#>  processx      3.3.1      2019-05-08 [2] CRAN (R 3.6.0)                
#>  ps            1.3.0      2018-12-21 [2] CRAN (R 3.6.0)                
#>  R6            2.4.1      2019-11-12 [2] CRAN (R 3.6.2)                
#>  Rcpp          1.0.4.6    2020-04-09 [2] CRAN (R 3.6.3)                
#>  remotes       2.1.0      2019-06-24 [2] CRAN (R 3.6.1)                
#>  rlang         0.4.4      2020-01-28 [2] CRAN (R 3.6.0)                
#>  rmarkdown     2.3        2020-06-18 [1] CRAN (R 3.6.3)                
#>  rprojroot     1.3-2      2018-01-03 [2] CRAN (R 3.6.0)                
#>  sessioninfo   1.1.1      2018-11-05 [2] CRAN (R 3.6.0)                
#>  stringi       1.4.3      2019-03-12 [2] CRAN (R 3.6.0)                
#>  stringr       1.4.0      2019-02-10 [2] CRAN (R 3.6.0)                
#>  testthat      2.3.2      2020-03-02 [2] CRAN (R 3.6.3)                
#>  usethis       1.5.1.9000 2020-02-04 [2] Github (r-lib/usethis@e7c1f17)
#>  withr         2.1.2      2018-03-15 [2] CRAN (R 3.6.0)                
#>  xfun          0.8        2019-06-25 [2] CRAN (R 3.6.1)                
#>  yaml          2.2.0      2018-07-25 [2] CRAN (R 3.6.0)                
#> 
#> [1] C:/Users/lijiaxiang/Documents/R/win-library/3.6
#> [2] C:/Program Files/R/R-3.6.0/library

I am curious whether or it this default setting is OK or it is a bug? For now, I avoid it by deleting the first heading.

I think you try to start a bookdown project by building it from nearly nothing to the full book.
I would advise you to take the other approach: start with a full template book and remove what you don't want. In that case you would:

  • click on File | New Project
  • select new directory
  • select book project using bookdown

This will generate the project. If you name the project EconKid the resulting file will also be named EconKid .

When I did this I saw that also two .yml files were generated. The one with name _bookdown.yml contains a line with book_filename: "EconKid" .

Maybe you solve your problem by just adding a _bookdown.yml with an adapted book_filename . But I advise you to have a look at the full template setup.

1 Like

The result you get is the expected one. bookdown:gitbook is designed to be used with a bookdown project, and not a single document. There are special feature by default you want for a book, like splitting by chapter.

The help page of ?bookdown:gitbook details the split_by argument. By default, it is set to chapter

chapter means split the file by the first-level headers;

That is why you get a file named by the first level header.

If you don't want that, you need to change it according to the documentation. Like none or rmd. It depends on what you want to do with this gitbook format, outside of a bookdown project.

Hope it helps.

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