Content
Typically when creating a website there are various common elements you want to include in all pages (e.g. output options, CSS styles, header and footer elements, etc.). Here’s some additions to the example above that makes use of common elements:
_site.yml
name: "my-website"
navbar:
title: "My Website"
left:
- text: "Home"
href: index.html
- text: "About"
href: about.html
output:
html_document:
theme: cosmo
highlight: textmate
include:
after_body: footer.html
css: styles.css
footer.html
<p>Copyright © 2016 Skynet, Inc. All rights reserved.</p>
styles.css
blockquote {
font-style: italic
}
Note that we’ve included an output
element within our _site.yml file. This defines shared output options for all R Markdown documents within a site. Note that individual documents can also include their own output options, which will be merged with the common options at render time.
As part of our common output options we’ve specified an HTML footer (via the include: after-body:
option) and CSS stylesheet. Note that you can also include HTML before the body or in the document <head>
, see the documentation on includes for more details.
In addition to whatever common options you define, the are two output options which are automatically set when rendering a site:
The
self_contained
option is setFALSE
; andThe
lib_dir
option is set tosite_libs
.
These options are set so that dependent files (e.g jQuery, Bootstrap, HTML widget libraries, etc.) are shared across all documents within the site rather than redundantly embedded within each document.