Can I add a "go to top" button to an HTML document rendered in R Markdown?

It's actually really easy. Simply insert this line of code at the end of your document (or wherever you want to put it):

 <a href="#top">Back to top</a>

This should do the trick. Atleast it works with html markdown documents made with knitR.

If you want to create a drop down element, you have to look into html forms and select option.


This is a bit dated but I was looking for this today.

I ended up adding this at the end of my mark down pages.

[Back to top](#) // any text here would work unless you want to point to a particular id in the html

And it seems to work fine too. I mean it will be converted to the same html as the above but at least you can use the md syntax