Setting up Utterances (Utteranc.es) with bookdown

Continuing the discussion from Commenting on RStudio Connect reports:

Utterances seems like an incredibly easy and beautiful way to enable feedback on #blogdown sites. In fact, many RBloggers using blogdown already have enabled this feature, including @apreshill link @robinlovelace link and probabbly many others.

I haven't seen it used in #bookdown however, is this possible? I've tried it but can't seem to get it running. What I have done so far:

  1. Installed utterances on a github organization and given it access to a repo (arc2r/comments)
  2. saved the suggested javascript code (as suggested on utteranc.es > " Enable Utterances) in a file in my bookdown project link
  3. included this html file in the header of each bookdown page by adding it to the yaml options like so (link):
bookdown::gitbook:
  includes:
    in_header: html/utterances.html

I see that the script was successfully integrated into the compiled html files, e.g. here, but I cannot see a comment section at the bottom of the page. What am I missing?

It says to position the script where you want the comments to show up. You’ve got it in your header, and so they can’t show up.

At least that’s what appears to be the problem after a brief glance.

So you suggest using in_footer: instead of in_header: in the YAML config?

Yes, that’s the first thing I would try.

Ok, I did that (and have tried it before), but now the script is not even integrated into the html documents (e.g. index.html), as it was before.

Sorry. I think the proper config code would be:

bookdown::gitbook:
  includes:
    after_body: html/utterances.html 
1 Like

That solved it! Thank you so much :heartbeat:

1 Like

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.