Editing the rmd files from a gitbook in bookdown.org

Is it possible to publish a gitbook in bookdown.org and include the rmd source files for editing to facilitate collaborations among authors?

I used bookdown::publish_book(), but I cannot access the red files from bookdown.org to edit the rmd files.

I think that's the setup most people use! For example, Geocomputation with R is here:

If you click on the little editing pencil, it will take you to the GitHub repo, which includes the Rmd files (obviously you can't edit them directly for someone else's repo to which you don't have access, but this allows you to fork and do pull requests etc.)

2 Likes

To point you to the documentation for edit button, you can get collaboration with bookdown by adding the edit configuration to your bookdown yaml

edit : a link that collaborators can click to edit the Rmd source document of the current page; this was designed primarily for GitHub repositories, since it is easy to edit arbitrary plain-text files on GitHub even in other people’s repositories (if you do not have write access to the repository, GitHub will automatically fork it and let you submit a pull request after you finish editing the file). This link should have %s in it, which will be substituted by the actual Rmd filename for each page.

I would add that to get your book listed on bookdown.org you have to follow this guidelines
https://bookdown.org/home/about/#how-to-get-your-book-listed-on-bookdown-org

2 Likes

Thank you both, however I cannot see the little pencil.

I tried, bookdown::publish_book(render = "server")

but received the following error:

This item is incomplete.

This Item has not been fully deployed. Please try publishing again.

Check the Logs tab for errors if deployment fails.

Is there a way to publish my book and have the little pencil to edit files?

Manuel

The file edition feature is just a link toward github that allows you to edit file and do PR in github repo. If you set up automatic deployment the book could be updated. The activation of the edition button is through the bookdown configuration in the yaml file. Follow the doc.

Regarding the error, as you selected render = server, the rendering process of bookdown happened on the server and something went wrong. Follow the log or render locally before publishing.

Read carefully the guideline in the book about

  • bookdown configuration and options
  • deployment of bookdown book
  • having github as source control

The best way for you as the author to edit the book is through modifiying directly the rmd file locally and push change to github repo.

Thank you Christophe,

I tried with github and RStudio, but I couldn´t push the book.

I am trying with bookdown.org now.

I used publish_book(), and it works, but I tried publish_book(render = "source") I got the error that I mentioned before. I will keep trying.

Manuel

What do you mean by that ?

Why do you need to push source if publish_book() work ?
On bookdown.org, I think you only need to publish html unless you want your book to be rebuild on the server. Personally, I think it is easier to render locally the push (or you something like travis and build within a docker container then push).

The error you got could be because anything. First guess is an R :package: that tries to be installed on the server but can't.

For me, when I put the "%s" into the edit link of the yaml, it is not replaced in the html file when I knit it

For example, I have in the yaml

edit: https://github.com/myusername/myrepo/edit/master/pathToIndexRmdFile/%s

and when I inspect the html file, the %s is not replaced by index.Rmd, and when I click on the edit button, it brings me to the webpage with "%s" in it. However, if I replace "%s" with index.Rmd, the correct Github editing page pops up.

I was wondering if anyone knows why the "%s" is not replaced by knitr

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.