build_home: Build home section

Description Usage Arguments Home page Sidebar Images and figures Package logo YAML config - home YAML config - authors

View source: R/build-home.R

Description

This function generates the home page, converts .md files found in the package root (and in .github/), and builds an authors page from DESCRIPTION and inst/CITATION (if present).

Usage

1
build_home(pkg = ".", override = list(), preview = NA, quiet = TRUE)

Arguments

pkg

Path to package.

override

An optional named list used to temporarily override values in _pkgdown.yml

preview

If TRUE, or is.na(preview) && interactive(), will preview freshly generated section in browser.

quiet

Set to FALSE to display output of knitr and pandoc. This is useful when debugging.

Home page

The home page (index.html) is generated from _pkgdown/index.md, index.md, or README.md, in that order. Most packages will use README.md because that's also displayed by GitHub and CRAN. Use index.md if you want your package website to look different to your README, and use _pkgdown/index.md if you don't want that file to live in your package root directory.

If you use index.Rmd or README.Rmd it's your responsibility to knit the document to create the corresponding .md. pkgdown does not do this for you because it only touches files in the doc/ directory.

Sidebar

The sidebar is automatically populated with:

Images and figures

If you want to include images in your README.md, they must be stored somewhere in the package so that they can be displayed on the CRAN website. The best place to put them is man/figures. If you are generating figures with R Markdown, make sure you set up fig.path as followed:

1
2
3
4
5
```{r, include = FALSE}
knitr::opts_chunk$set(
  fig.path = "man/figures/"
)
```

Package logo

If you have a package logo, you can include it at the top of your README in a level-one heading:

1
# pkgdown <img src="man/figures/logo.png" align="right" />

init_site() will also automatically create a favicon set from your package logo.

YAML config - home

To tweak the home page, you need a section called home.

By default, the page title and description are extracted automatically from the Title and Description fields DESCRIPTION (stripping single quotes off quoted words). CRAN ensures that these fields don't contain phrases like "R package" because that's obvious on CRAN. To make your package more findable with google, it's good practice to override the title and description, thinking about what people might search for:

1
2
3
4
5
6
home:
  title: An R package for pool-noodle discovery
  description: >
    Do you love R? Do you love pool-noodles? If so, you might enjoy
    using this package to automatically discover and add pool-noodles
    to your growing collection.

(Note the use of YAML's >; this is a convenient way of writing paragraphs of text.)

The sidebar links are automatically generated by inspecting the URL and BugReports fields of the DESCRIPTION. You can add additional links with a subsection called links, which should contain a list of text + href elements:

1
2
3
4
home:
  links:
  - text: Link text
    href: http://website.com

READMEs usually start with an <h1> containing the package name. If that feels duplicative with the package name in the navbar you can remove it with strip_header: true:

1
2
home:
  strip_header: true

YAML config - authors

The "developers" list is populated by the maintainer ("cre"), authors ("aut"), and funder ("fnd") from the DESCRIPTION. You can modify their display on the home page by adding a subsection for authors. The author name should match the value in DESCRIPTION:

1
2
3
4
authors:
  name:
    href: "http://name-website.com"
    html: "<img src='name-picture.png' height=24>"

Paradigm4/pkgdown documentation built on June 3, 2020, 12:30 a.m.