This is a tutorial on how you can use Distill to host blog in R. Before the end of this article, you’ll also learn to create, build and host your own website/blog using R.
Since last 4 years, I had been using WordPress for hosting my blogs. It is great platform for beginners to begin with blogging. However, I have migrated from WordPress to Distill blog.
Distill is a web publishing format used for scientific and technical writing. Using Rmarkdown, you can create a distill blog or website.
Distill is based onDistill web framework. It combines the technical writing features of Distill with R Markdown. You’ll find distill awesome because they’re:
Simple in design:Distill is simple in design. It’s typography and design adapts well in Mobile.
Host for free:You need to pay certain fees to host your website right. But not so with Distill. It generates static html page. It means, we can host our website for free. You can choose with GitHub Pages, Netlify or any hosting providers who offers free web page hosting.
Fast and Secure:Distill is a static site generator. So, it doesn’t have any server side processing like (PHP, MySQL in WordPress). The html pages are served instantly and are secure in nature.
Support technical writing:Out of box, distill comes with LaTeX math, citation, footnotes, acknowledgment, and bibliography support. So, it’s great for publishing your technical writings and scientific publications.
Open Source Blogging:We can open source our blog. Anyone can submit their pull request to suggest changes in the blog.
You can find more detailed about the distill featureshere.
You can easily create and host Distill blog in R using RStudio.
First, you need to install Distill R package.
Now on your RStudio (top-left), File > New Project > Create Distill Blog.
You can configure your blog setting with_site.ymlfile.
name: "Binod Jung Bogati" title: "My Data Science Blog" description: | Hi, I'm Data Scientist at Numeric mind. This is my blog about Rstats and Data Science. output_dir: "_site" navbar: right: - text: "Home" href: index.html - text: "About" href: about.html output: distill::distill_article
You can create new distill blog post using create_post() function. To skip date prefix (10-01-2021), you can set it to NULL as below.
distill::create_post("Creating Distill Blog in R", date_prefix = NULL)
After that, distill will generate Rmarkdown file inside a folder. You can change your name and add content in your post.
Once you’re done with changes, you may knit your article/post (Ctrl+Shift+K).
You can open index.Rmd file from Files (right-bottom). Then knit the index.Rmd file to generate a Home page (index.html).
Note: All the blog posts are located at the **_posts** directory.
We are going to create GitHub Repository for our distill blog. This is because, we can update our blog withgit push.
- Go to Tools > Terminal > New Terminal (Alt+Shift+R). Then, push all your changes to GitHub.
You can refer guide toupload project in GitHub.
git add . git commit -m "added new blog" git remote add origin https://github.com/bjungbogati/my-blog.git git push -u origin master
We can easily host our distill blog, once it’s available on GitHub repository. Here, we’re going to use Netlify (instead of GitHub Pages).
First signup toNetlify.com
After login, add New site from Git > Connect to GitHub > Pick repository with distill blog.
In Distill, you can customize your blog theme with style.css.