Is there a place we can put non-blog files (pdf files) in blogdown?

Hello,

I have a blogdown based blog. I want to put link to a pdf file that goes along with the blog post. The blog post is in content/post folder. I wasn't sure where I would put the pdf file and how I would reference the link to it in the Rmd file for the blog post. I would appreciate any help on this.

Shankar

Yes, you can put a "non-blog" content on your blogdown blog.

The easiest way (though it can get a little messy if you use it too often, or to share too many files) is to copy your pdf file directly to the /public directory of your blog. It will appear on root directory of your website - I happened to do this with my blog a while back, so this is how it looks like: www.jla-data.net/iota.pdf

There are other, more fancy approaches - such as using your /static directory as described by Yihui Xie - but if you are looking for a quick & dirty solution this one works.

3 Likes

I found this blogpost helpful when researching the same problem (although it is essentially rehashing the link provided by @jlacko).

2 Likes

The steps in the helpful links others have given you are based on need to render an Rmd file to some format (I think). So if that's what you need to do, follow those steps. :grin:

However, if you have a document that doesn't need rendering, the main step you need is the "put it in the static directory" step. You can then refer to that file in your blog via the file path.

Here's an example. I have a subdirectory called "pdf" in my static folder where I store PDF documents I want to link to on my website. If I have a file named "file1.pdf" I can insert a link to it via markdown syntax like: See the [handout](/pdf/file1.pdf) for more info. Note the path starts with a forward slash, which is key.

Also see this github comment, which I think makes this all clearer than I just did. :wink:

6 Likes

Thanks for all the responses. The blog is hosted using docs folder in github (links are below):

I put a folder called presentationFiles/jun2018 with 2 pdfs in static folder. When I tried using /presentationFiles/jun2018 in the Rmd document, it didn't work. I am guessing it is because of being rendered in docs folder. So for now I am just using an absolute path to the main github repo (probably not ideal but works for now).

Thanks again for your responses. I appreciate the help.