Is it possible to password protect one page of a website made using R blogdown
, published using the free version of Netlify?
If not, it it possible to host a password protected RMD file on a blogdown website? I tried using the encryptedRmd
package but I don't think it's meant for this..
I was able to add basic password protection for one page on my website using Brent Scott's pagecryptr
package, which is a R-wrapper for PageCrypt. The set up is very simple thanks to the R package.
password.html
.[[menu.main]]
name = "Portfolio"
url = "/Portfolio/"
Note that you do not need to create a RMD or HTML file for this page because we'll be using pagecryptr
to create it.
pagecryptr
install.packages("drat")
drat::addRepo("brentscott93")
install.packages("pagecryptr")
library(pagecryptr)
pagecryptr
to password protect the file:if(interactive()){
file <- "~/password.html"
pagecryptr(file, "password123", out_file = "~/content/Portfolio.html")
}
Notice how pagecryptr
is taking the file we want to password protect (password.html
) and writing HTML for it that corresponds to the page we created in our TOML (Portfolio.html
). The second argument contains the password you want to use for the website (in this example, it's password123
).
Commit Portfolio.html
to GitHub and you will have a password protected page on your website!