We have a distill website. It has a nice about page, courtesy of the postcards package. Now, we can add a blog to it. Let’s use this last activity time in our breakouts to “choose your own adventure”- three options:
- Add a blog
- Add/hone your site theme
- Add some content to show off your R programming skills!
Back in your console, we can add a blog, using distill:
If you do this with a blog already, it just adds a single post. But if you do this without posts set up, it does some nice things for you:
Creates a directory called
_posts/to hold all your future blog posts.
Creates a new post with a “slug” including the date and the name of the post (here, mine was
Your new post should open up - go ahead and knit this post. Posts in distill need to be knit intentionally, so they will never be automatically built when you rebuild your website.
We also probably want to add a listing page to list all our blog posts. Do this by adding a blank
.Rmd file to your project root, I’ll call mine
blog.Rmd but there is no magic to this file name:
Then open up your new
blog.Rmd and add a YAML (no content below the YAML):
--- title: "Blog" # any name you want here listing: posts # do this exactly ---
Finally, add a link to your blog in your upper navbar so people can actually find it! Do this by editing
_site.yml one last time (remember, since my listing
.Rmd is named
blog.Rmd, then the href I want to link to is
navbar: right: - text: "Home" href: index.html - text: "About" href: about.html - text: "Blog" # add href: blog.html # add
Now, admire your final polished product!
Now you may be wishing that your postcards page was your homepage- the place where visitors first land when they visit your website. The homepage in a distill website is named
index.Rmd, so we need to remove the current
index.Rmd file and replace it with
about.Rmd. But we cannot just rename the files…
If you open up
index.Rmd, you should see this yaml:
--- title: "iyo" description: | Welcome to the website. I hope you enjoy it! site: distill::distill_website ---
site key is very important to keep in the
index.Rmd file. Steps:
Let’s start by adding
site: distill::distill_websiteto the yaml of your postcards page, mine is named
After doing that, you can delete
Finally, clean up your
_site.yml- you can remove the link we added above to
Re-build your site and your shining face should greet you from the homepage!
Follow the docs here: https://rstudio.github.io/distill/website.html#theming
Need inspiration? Try one of our example themes.
_site.yml file? Add the theme line there:
name: "Introduce Yourself Online" title: "iyo-distill" description: | iyo-distill output_dir: "docs" theme: iyo.css << here! navbar: right: - text: "Home" href: index.html - text: "About" href: about.html output: distill::distill_article