Professional Documents
Culture Documents
blogdown: Creating Websites with R Markdown Yihui Xie full chapter instant download
blogdown: Creating Websites with R Markdown Yihui Xie full chapter instant download
https://ebookmass.com/product/creating-responsive-websites-using-
html5-and-css3-a-perfect-reference-for-web-designers-varun-gor/
https://ebookmass.com/product/divestitures-creating-value-
through-strategy-structure-and-implementation-emilie-r-feldman-2/
https://ebookmass.com/product/divestitures-creating-value-
through-strategy-structure-and-implementation-emilie-r-feldman/
https://ebookmass.com/product/discover-digital-libraries-theory-
and-practice-1st-edition-iris-xie/
Random Process Analysis With R Marco Bittelli
https://ebookmass.com/product/random-process-analysis-with-r-
marco-bittelli/
https://ebookmass.com/product/basic-statistics-with-r-reaching-
decisions-with-data-stephen-c-loftus/
https://ebookmass.com/product/easy-statistics-for-food-science-
with-r-abdulraheem-alqaraghuli/
https://ebookmass.com/product/practical-highcharts-with-angular-
your-essential-guide-to-creating-real-time-dashboards-2nd-
edition-sourabh-mishra/
https://ebookmass.com/product/practical-highcharts-with-angular-
your-essential-guide-to-creating-real-time-dashboards-2nd-
edition-sourabh-mishra-2/
blogdown
Creating Websites
with R Markdown
Chapman & Hall/CRC
The R Series
Series Editors
John M. Chambers Torsten Hothorn
Department of Statistics Division of Biostatistics
Stanford University University of Zurich
Stanford, California, USA Switzerland
Yihui Xie
Amber Thomas
Alison Presmanes Hill
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts
have been made to publish reliable data and information, but the author and publisher cannot assume
responsibility for the validity of all materials or the consequences of their use. The authors and publishers
have attempted to trace the copyright holders of all material reproduced in this publication and apologize
to copyright holders if permission to publish in this form has not been obtained. If any copyright material
has not been acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information storage
or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access
www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc.
(CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization
that provides licenses and registration for a variety of users. For organizations that have been granted a
photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are
used only for identification and explanation without intent to infringe.
List of Figures xv
Preface xvii
1 Get Started 1
1.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Update . . . . . . . . . . . . . . . . . . . . . . 2
1.2 A quick example . . . . . . . . . . . . . . . . . . . . . 2
1.3 RStudio IDE . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Global options . . . . . . . . . . . . . . . . . . . . . . 10
1.5 R Markdown vs. Markdown . . . . . . . . . . . . . . . . 12
1.6 Other themes . . . . . . . . . . . . . . . . . . . . . . . 17
1.7 A recommended workflow . . . . . . . . . . . . . . . . 19
2 Hugo 23
2.1 Static sites and Hugo . . . . . . . . . . . . . . . . . . . 23
2.2 Configuration . . . . . . . . . . . . . . . . . . . . . . 25
2.2.1 TOML Syntax . . . . . . . . . . . . . . . . . . . 26
2.2.2 Options . . . . . . . . . . . . . . . . . . . . . . 28
2.3 Content . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3.1 YAML metadata . . . . . . . . . . . . . . . . . 31
2.3.2 Body . . . . . . . . . . . . . . . . . . . . . . . 32
2.3.3 Shortcode . . . . . . . . . . . . . . . . . . . . 32
2.4 Themes . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.4.1 The default theme . . . . . . . . . . . . . . . . 34
2.5 Templates . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.5.1 A minimal example . . . . . . . . . . . . . . . . 39
ix
x Contents
3 Deployment 63
3.1 Netlify . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.2 Updog . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.3 GitHub Pages . . . . . . . . . . . . . . . . . . . . . . . 67
3.4 Travis + GitHub . . . . . . . . . . . . . . . . . . . . . . 70
3.5 GitLab Pages . . . . . . . . . . . . . . . . . . . . . . . 74
4 Migration 77
4.1 From Jekyll . . . . . . . . . . . . . . . . . . . . . . . . 78
4.2 From WordPress . . . . . . . . . . . . . . . . . . . . . 82
4.3 From other systems . . . . . . . . . . . . . . . . . . . . 83
5 Other Generators 85
5.1 Jekyll . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.2 Hexo . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.3 Default site generator in rmarkdown . . . . . . . . . . . 91
5.4 pkgdown . . . . . . . . . . . . . . . . . . . . . . . . . 92
Appendix 95
A R Markdown 95
B Website Basics 99
B.1 HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
B.2 CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
B.3 JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . 110
B.4 Useful resources . . . . . . . . . . . . . . . . . . . . . 114
B.4.1 File optimization . . . . . . . . . . . . . . . . . 114
B.4.2 Helping people find your site . . . . . . . . . . . 115
Bibliography 141
Index 143
List of Tables
xiii
List of Figures
2.1 Possible files and folders created when you create a new site
using blogdown. . . . . . . . . . . . . . . . . . . . . . . 25
2.2 A tweet by Jeff Leek. . . . . . . . . . . . . . . . . . . . . 33
2.3 Edit a text file online on GitHub. . . . . . . . . . . . . . . 58
xv
Preface
Carlos’s words resonated very well with me, although they were a little ex-
aggerated. A well-designed and maintained website can be extremely help-
ful for other people to know you, and you do not need to wait for suitable
chances at conferences or other occasions to introduce yourself in person
to other people. On the other hand, a website is also highly useful for your-
self to keep track of what you have done and thought. Sometimes you may
go back to a certain old post of yours to relearn the tricks or methods you
once mastered in the past but have forgotten.
We introduce an R package, blogdown, in this short book, to teach you how
to create websites using R Markdown and Hugo. If you have experience with
creating websites, you may naturally ask what the benefits of using R Mark-
down are, and how blogdown is different from existing popular website plat-
forms, such as WordPress. There are two major highlights of blogdown:
xvii
xviii Preface
Please do not be misled by the word “blog” in the package name: blogdown
is for general-purpose websites, and not only for blogs. For example, all au-
thors of this book have their personal websites, where you can find infor-
mation about their projects, blogs, package documentations, and so on.2 All
their pages are built from blogdown and Hugo.
If you do not prefer using Hugo, there are other options, too. Chapter
2
Yihui’s homepage is at https://yihui.name. He writes blog posts in both Chinese
(https://yihui.name/cn/) and English (https://yihui.name/en/), and documents his soft-
ware packages such as knitr (https://yihui.name/knitr/) and animation (https://yihui.
name/animation/). Occasionally he also writes articles like https://yihui.name/rlp/ when
he finds interesting topics but does not bother with a formal journal submission. Amber’s
homepage is at https://amber.rbind.io, where you can find her blog and project pages.
Alison’s website is at https://alison.rbind.io, which uses an academic theme at the mo-
ment.
Preface xix
Chapter 1 aims at getting you started with a new website based on blogdown:
it contains an installation guide, a quick example, an introduction to RStu-
dio addins related to blogdown, and comparisons of different source docu-
ment formats. All readers of this book should finish at least this chapter (to
know how to create a website locally) and Section 3.1 (to know how to pub-
lish a website). The rest of the book is mainly for those who want to further
customize their websites.
Chapter 2 briefly introduces the static website generator Hugo, on which
blogdown is based. We tried to summarize the official Hugo documentation
in a short chapter. You should consult the official documentation when in
doubt. You may skip Section 2.5 if you do not have basic knowledge of web
technologies. However, this section is critical for you to fully understand
Hugo. We have spent the most time on this section in this chapter. It is very
technical, but should be helpful nonetheless. Once you have learned how to
create Hugo templates, you will have the full freedom to customize your web-
site.
Chapter 3 tells you how to publish a website, so that other people can visit
it through a link. Chapter 4 shows how to migrate existing websites from
other platforms to Hugo and blogdown. Chapter 5 gives a few other options
if you do not wish to use Hugo as your site generator.
Appendix A is a quick tutorial on R Markdown, the prerequisite of blogdown
if you are going to write R code in your posts. Appendix B contains basic
knowledge about websites, such as HTML, CSS, and JavaScript. If you really
care about your website, you will have to learn them someday. If you want
to have your own domain name, Appendix C provides an introduction to
how it works. We have also covered some optional topics in Appendix D for
advanced users.
Another random document with
no related content on Scribd:
Käy ilma vienommin,
Hiljallansa
On kukkaskansa,
Miettivi, kuulevi, tuoksuvi hienommin.
Teitä, vierahat,
Tänne kun tullen
Ja lausuen, laulain
Mielenne innon
Mullekin soitte,
Teitä mä kiitän!
Laaksohon tänne,
Puiden latvahan
Laskevi joskus
Outonen lintu.
Ja illan tullen,
Kaikk' kun on hiljoin,
Käy satakielisen liiretys viljoin.
Sen kummaa tahtia
Kielien soitoll'
Ei kenkään ennä.
Sen kilvalla laulaa
Huokuvin rinnoin
Ei kenkään voi;
Sulokaunoisesti sen ääni soi.
JAUFFRED.
TRISTAN (Jolanthalle).
Lauluamme
Te vertailette satakielen lauluun.
Oi, jospa oisin joku, vaikka pienin,
Vaikk' köyhin noista lintusista, jotk on
Luonanne täällä, saadakseni kuulla
Yhäti noita sulosäveleitä,
Joit' teidän rinnassanne heräjää.
JAUFFRED.
JOLANTHA.
JAUFFRED.
JOLANTHA.
Raimbaud'ksi häntä
Nimitetään.
JAUFFRED.
Raimbaud'ksi? Ritari
Hän onko?
JOLANTHA.
Ritar'?
JAUFFRED.
Eli sotilas.
Kypärä, kilpi, kultakannukset
Häll' onko? Mikä hänen virkans' on?
JOLANTHA.
JAUFFRED.
JOLANTHA (kummastellen).
Tarkoin?
JAUFFRED.
JOLANTHA
JOLANTHA.
Niin tääll'
Ei ole… siinä oikeassa oot…
En tiedä, mistähän se tulee. Muuten
En yksin ole täällä milloinkaan.
Mut varroppas, ma kutsun… Bertrand kyll'
On ilostuva teidän tulostanne.
(Menee huoneesen.)
JAUFFRED.
JAUFFRED.
TRISTAN.
JAUFFRED (totisesti).
TRISTAN.
JAUFFRED.
Älkää jatkako!
Te haaveksitte! Itse tiedätten
Te, mitä tulevainen aika teilt'
On vaativa. Mut hurmattu te ootte.
Tuo liekki rinnastanne riistäkää.
TRISTAN.
JAUFFRED.
JOLANTHA.
Olettenko täällä?
JAUFFRED.
TRISTAN.
JOLANTHA.
Niin,
He kyllä tulevat. He viinamarjain
Korjuussa varmaan ovat. Siell' on mun
Myös tapa olla. Muuten joku heistä
Mun luonan' on.
Te jäätte tänne?
TRISTAN.
Jään.
JAUFFRED.
JOLANTHA (kuunnellen).
Kohta taas
Hän palajaa. Mut, anteeks' antakaatte,
— Erääsen rikokseen mä syypää oon,
Jon sovittaa mä jällen tahdon. Teidän
Uinaillessanne äsken, pienen kanneen
Ma otin teiltä, muistoksenne vaan.
Täss' on se.
JOLANTHA.
Missä?
TRISTAN.
JOLANTHA.
TRISTAN.
Mulle suokaa
Sen sijaan joku punaruusu tuolta,
Mi nostaa teidän kuvananne latvans'
Ylitse muiden kukkain vähempäin.
JOLANTHA.
TRISTAN.
Ah, valkoinenp'
On tämä! Antakaatte punainen,
Mi kaunis on kuin tekin.
JOLANTHA.
Punainen?
Mitäpä tarkotat?
TRISTAN (osottaen).
JOLANTHA.
TRISTAN.
Ei, ennemmin
Mä pidän tään, jon valitsitte te,
Jon poimi teidän kätenne. Ja oikein
Kun mietin, kiitänkin mä valintaanne.
Valkoinen ruusu, jonka helmass' uinuu
Noin raskasmielinen ja vaalas puna,
Tän puiston haaveellisen kaunoisuuden
Vertainen on. Yks ruusu antakaa
Nyt viel', ja valkoinen. Ma hattuhuni
Ne panen molemmat, ja tahdon kantaa
Ne teidän Iempivärinänne.
Täss'
On ruusu. Tätäkö sä tarkotit?
TRISTAN (hämmästyy).
Mä pyysin valkoista.
JOLANTHA.
TRISTAN.
Tää — tää…
(Erikseen:)
Haa, mikä mun aavistaa!
(Ääneen:)
Hei, sanokaas —
(Pitää Jolanthan edessä noita kahta ruusua ja muutamia
muita, joita hän itse poimii lisäksi.)
No annappa ne tänne.
TRISTAN.
Ei, koskematta.
JOLANTHA.
TRISTAN (syrjään).
JOLANTHA.
Ei, sä erhetyt.
Kun tietoa ma tahdon jostakin,
Minkaltaista se ompi, kuinka monta
Niit' on, niin tuntelen ma. Sehän selvää.
TRISTAN (hämillänsä).
Niin — oikeassa ootte — mutta väliin…
JOLANTHA.
TRISTAN.
Ma tarkotan,
Ett'.. että löytyy kappaleita, joita
Vaan väristänsä erottaapi, niin
Kuin monet kukkaslajit, monet aineet.
JOLANTHA.
TRISTAN.
JOLANTHA.
TRISTAN (erikseen).
Oi kummaa!
(Ääneen.)
Sanottu eikö ole teille, että
Kaikk' kappalehet voipi erottaa
Etäältä kautta… näön, näkemällä?
JOLANTHA.
TRISTAN (erikseen).
Mistä maasta
Sa oot? Sull' lauseit' ompi, joita kenkään
Ei täällä tunne; paljon, kuin jo sanoin,
Puheessas on semmoista, joka mulle
On outoa ja uutta. Onkohan
Se laakso, jost' oot sinä kotoisin,
Niin aivan toisen kaltainen kuin tää?
Siis tänne jää, jos voit, ja sitä mulle
Opeta, mitä tiedostani puuttuu.
TRISTAN.
JOLANTHA.
TRISTAN.
Ah, vähän tarkka kuulunta teit' auttaa.
Mut — sanokaas: sen huomanneet kai ootte,
Ett' ilman erinäistä tarkotusta
Ja hyötyä ei ole yksikään
Ruumiinne kauniin jäsenistä. Sormin
Ja käsin tartutten te esineisin;
Jalkanne, vaikka pienet kyllä, vievät
Helposti teitä, minne halajatte.
Ja korvan koukeroisen kautta lauseen,
Sävelten ääni sieluhunne saapuu.
Puheenne käypi huuliltanne. Rinta
On suojus kevykäisen hengen tuon,
Mi huoletonna nousevi ja laskee.
JOLANTHA.
TRISTAN.
TRISTAN.
Oi anteeks' suokaa
Mun kysymyksen' oli julma. Moinen
Sisäinen sielun kirkkaus on teillä,
Ett'ette kaipaa tuota, jot' on meidän
Valosta lainaaminen silmäin kautta.
Tulisko aatella, ett' alkuperää
Oudoista olennoista ootte, joill on
Avuja toisenlaisia kuin meillä?
Tääll' yksin elätten; tää laakso näyttää.
Kuin loihdituksi vuorten lomihin.
Idästä, Peri-parvi kerallanne
Te tulittenko? Tyttäriä Brahman
Te lietto, jonkun Magin tänne tuoma
Luot' Induksen? Oi kaunis tuntematon!
Jos syntyisin te ootte ihmisistä,
Kut maata äidiksensä mainivat,
Jos ootte mieltyväinen tään maailman
Katoavaiseen riemuhun kuin minä,
Niin lempeästi ottakaatte vastaan
Ritarin suosittelu: kuulkaa hänen
Lupaustansa, ett' ei nainen ykskään,
Vaikk' ihanuuden, synnyn kautta kuinka
Etevä ois se, poista tuota kuvaa,
Jonk' ootte te mun sieluun' painaneet.
TRISTAN (Jolanthalle).
JOLANTHA.
TRISTAN.
Ma tulen jällen,
Ja pian — tulen tänäpänä vielä.
Ettenkö tahdo käsin tunnustella,
Kuin pitkä oon, ett' taas, kuin yhdymme,
Te huokeammin minut tunnetten?
JOLANTHA.
TRISTAN.
JOLANTHA.