How to set up a working HTTPS encryption with netlify, blogdown, and rbind.io
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
If you host a website, it is worth considering using the secure HTTPS
encryption instead of HTTP
(also in light of the GDPR).1 As someone who is less experienced in setting this up, this can be challenging, particularly if you use a domain that you do not personally own. This post is meant to give a (really) short step-by-step guide for those in a similar situation.
The situation
I build my homepage using the wonderful blogdown
package with a customized version of the Hugo Academic theme. To deploy the website, I rely on Netlify, which works like a charm! Since I did not want the default netlify.app
domain (suffix) to be my domain, I oppened an issue to request the rbind.io
suffix. Setting this up is extremely straightforward and well explained here. Well, now that this worked, I wanted to be able to use HTTPS
instead of HTTP
. And here, the challenge began.
The solution ?
In retrospect, it was all nicely explained in the answer to my issue, which I was not aware of back then. I hope this post will pop up for future users and point them quickly to the solution.
The excellent description by Yihui Xie describes everything what you need to do (and to know). Here is what I did using my own words:
- Open your website
.Rproj
in RStudio - Open a new plain
Text File
- Copy the following line and replace the word
domain
so that it matches your website name (for me, it would becosimameyer
).
http://domain.rbind.io/* https://domain.rbind.io/:splat 301!
- Save the file as
_redirects
(no suffix needed) in thestatic
folder of your website. This is how the (simplified) root overview of your folder should look like:
├── R ├── README.md ├── assets ├── config ├── config.toml ├── content │ ├── about │ ├── authors │ ├── courses │ ├── home │ ├── post │ ├── project │ ├── publication │ ├── slides │ └── talk ├── index.Rmd ├── libs ├── Your-website.Rproj ├── netlify.toml ├── public ├── resources ├── static │ └── _redirects └── themes
You’ll see that _redirects
is located directly in the static
folder.
Well, and that’s it – this little trick did the magic for me! ?
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.