The Bookdown book I made is no longer rendering correctly.

I created a book entitled "Fantastic Genes and Where to Find Them" for a course. You can view it here:

I used this manual successfully in the Fall of last year. This year I decided to combine chapters 1 and 2 and change the heading of chapter 1. I republished the book but the old chapter 1 can still be found (via google) and the table of content link for chapter 1 no longer works in my republished book. Instead, I get a "404 page not found" error.

Upon closer examination,
I discovered that I can find the correct chapter 1 if I manually input
1 Genes, Genomes and Genome Browsers | 09-Chapter or if I click the correct chapter 1 link following a google search.

What happened and how can I fix it? I am not a programmer but a biologist ... sadly.

I have another problem that I will ask later. It just seems like this whole thing started to get buggy unexpectedly this summer.

Hi Maria. My comments may not be helpful as I don't use I instead knit the book locally and then use ssh to send the appropriate files to my host. That said:

  • I assume you tried building the book multiple times to see if the issue persists?
  • Did you check whether your local book is different than the version?
  • When you say you "decided to combine chapters 1 and 2 and change the heading of chapter 1" what were the specific changes you made?
  • What are your various chapter names? Maybe you could post a screenshot or list of the directory? Are you following the conventions in 1.3 Usage | bookdown: Authoring Books and Technical Documents with R Markdown?
  • On can you see if the missing files (chapter1.html) are actually there?

You could also look try to look through the index.html file in the _book directory to see if this matches your expectation. (However, this requires that you can read html code.)

Hope this helps! - Bert

Thanks for the response. I did try knitting / building multiple times. And yes, my local book was different from the one uploaded to The local book looked fine, links worked fine.

To explain how I changed my book, I combined chapters 1 and 2 into a new chapter 1. I also changed the name of header one (#). Then I moved the content from chapter 3 into 2, chapter 4 into 3 etc. I also added #labels to each header one for all chapters so I could cross reference from within the book. The chapter names are all multiword phrases but the labels were boring: chapter1, chapter2 etc.

What was interesting is that I could find the old chapter 1 AND the new chapter 1 by replacing "chapter1" in the web address ("XXX/where-are-genes/chapter1") with the new or old chapter name (i.e. new chapter name: "XXX/where-are-genes/genes-genomes-and-genome-browsers" ). So yes. all the files were in but the link in the TOC of the book was not working because it was using "XXX/where-are-genes/chapter1" as its web address instead of what actually worked: "XXX/where-are-genes/genes-genomes-and-genome-browsers"

Anyway . . . I FIXED the problem by getting rid of the {#label} for chapter one, header one. This doesn't make any sense to me but I knew I didn't need it since I do not cross reference chapter 1 anywhere in my book. So problem solved but no idea why.

1 Like

Hi @megallegos !

I happy to help in order to explain.

First question before : Did you clean the old book folder ? The folder where the book is built ?
See about bookdown::clean_book()

This would be require in order to start fresh, and don't have your old HTML files be published. As you are merging old chapters, this is important because HTML files are derived from chapter. Also, their file name are derived from the title of the chapter or from the id you set {#id}

So it is possible that the id.html file was still there from the previous book build and the TOC would point to that old file.

Anyway, I am glad you found a solution. I would really advice to clean up the output dir anytime you are doing changes that are impacting the file structure.

# dry run
# delete
# rebuild book

Hope it helps

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.