![]() ![]() md files and puts them in the root directory (in the case of R Markdown pages) or the _posts directory in the case of R Markdown blog posts. When you push a new commit to the repository, the script above looks for. We choose only: source so that Travis doesn’t trigger itself when it pushes your site to the master branch, otherwise we would get an endless feedback loop. The output will then be deployed to another branch. ![]() Whenever you push commits to the source branch, Travis will notice and start a build. I have opted to use a branch called source but you can use whatever you like. GitHub says the final rendered web site files have to be on the master branch, so we want to push our source code somewhere else. ![]() branches:Ĭhoose the branch of your repository to which you will submit your code.įor a personal site-i.e. Pandoc is a key piece of software that R Markdown uses to convert documents between various formats.īy default, Travis seems to use an old version of pandoc (1.15 or so), which can cause unexpected errors when trying to render R Markdown documents.Īt the time of writing 1.17.2 seems to be the recommended version of pandoc for R Markdown, though I expect newer releases should be fine, too. The most minimal R package comprises a single file, called DESCRIPTION. To generate standalone R Markdown documents or web sites with Travis, you need to hoodwink the system into thinking it is building a real R package. R is natively supported in Travis thanks to work by the community.Ī Travis R build comes with pandoc and LaTeX, ostensibly for building R package documentation. Since we will be knitting R Markdown files into Markdown, we want Travis to have a copy of R installed. travis.yml that lives in the root of your Git repository.Īs a baseline, I recommend creating a file that contains the following configuration. Copy it to your clipboard.īack on Travis, on the settings page for your branch, create an Environment Variable with name GITHUB_PAT and paste the personal access token into the Value field. You will also need to generate a personal access token on GitHub, which grants Travis permission to push to your branch. ![]() It doesn’t actually do anything just yet, but now Travis knows to watch for future commits to this repo. In the Travis ‘Accounts’ screen, look for your site’s repository and switch it on (green tick). However, rather than running tests on software, we are going to be using Travis’s infrastructure to build our web site for us. Travis is a service designed to run unit tests on software packages so that bugs are not introduced during development. Once that is all working smoothly, sign up for a free Travis CI account. There are plenty of good guides for this on the web, so I won’t go into the details here. If you have not already done so, set up a regular GitHub Pages Jekyll site. What we are going to do instead is knit our R Markdown posts in the cloud, which automatically pushes the resulting plain Markdown files and images to GitHub, where they will be served by Jekyll like a regular site.įor reference, I have created a minimal working repository. Ideally, we want to be able to maintain our web site from anywhere we have access to a web browser, just as we would a WordPress or Blogger site. Jekyll is written in Ruby, which can be a pain to install on Windows and fiddly to configure for GitHub Pages. This is a nice, but incomplete solution, because it means we can only really write and edit posts from computers on which R, servr and Jekyll are installed. Yihui Xie 1 has added Jekyll support to the servr package and published a blog post and GitHub repository demonstrating how to use servr::jekyll to serve a Jekyll site locally with R Markdown. In this post I will explain how you can use Travis CI to knit R Markdown posts and deploy them to a GitHub Pages Jekyll site. How can we write and edit blog posts in R Markdown and serve them on GitHub Pages without having to build everything locally? Markdown is good, but R Markdown is even better, assuming we ever want to write anything involving plots or data analysis. Simply push your plain text Markdown content to a repository and the server-side Jekyll engine will render it for the web. GitHub Pages’ built-in Jekyll support makes it very easy for techie types to deploy static web sites. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |