Skip to content

Commit

Permalink
Recommend usethis::use_pkgdown_github_pages() everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Jun 5, 2024
1 parent 8f3a286 commit c2a6389
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' display of your site.
#'
#' # Build-ignored files
#' We recommend using [usethis::use_pkgdown()] to build-ignore `docs/` and
#' We recommend using [usethis::use_pkgdown_github_pages()] to build-ignore `docs/` and
#' `_pkgdown.yml`. If use another directory, or create the site manually,
#' you'll need to add them to `.Rbuildignore` yourself. A `NOTE` about
#' an unexpected file during `R CMD CHECK` is an indication you have not
Expand Down
12 changes: 5 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,15 @@ pak::pak("r-lib/pkgdown")
Get started with [usethis](https://usethis.r-lib.org/):

```{r, eval = FALSE}
# Run once to configure your package to use pkgdown
usethis::use_pkgdown()
# Run once to configure your package to use and deploy pkgdown
usethis::use_pkgdown_github_pages()
```

Then use pkgdown to build your website:

```{r, eval = FALSE}
pkgdown::build_site()
```
This adds the necessary components and sets up GitHub Actions for automatic site building when deploying.

This comment has been minimized.

Copy link
@hadley

hadley Jun 5, 2024

Member

I think we probably still want to mention build_site() here so people know how to build and preview locally.

Your `README.md` becomes the homepage, documentation in `man/` generates a function reference, and vignettes will be rendered into `articles/`. [^1]

This generates a `docs/` directory containing a website. Your `README.md` becomes the homepage, documentation in `man/` generates a function reference, and vignettes will be rendered into `articles/`. Read `vignette("pkgdown")` for more details, and to learn how to deploy your site to GitHub pages.
[^1]: If you don't use GitHub, you can use `usethis::use_pkgdown()` + `pkgdown::build_site()` to create a website.

This comment has been minimized.

Copy link
@hadley

hadley Jun 5, 2024

Member

I like the idea of the footnote, but I'd put it after "GitHub actions" on line 52.


### pkgdown 2.0.0 and Bootstrap 5

Expand Down
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,14 @@ pak::pak("r-lib/pkgdown")
Get started with [usethis](https://usethis.r-lib.org/):

``` r
# Run once to configure your package to use pkgdown
usethis::use_pkgdown()
# Run once to configure your package to use and deploy pkgdown
usethis::use_pkgdown_github_pages()
```

Then use pkgdown to build your website:

``` r
pkgdown::build_site()
```

This generates a `docs/` directory containing a website. Your
`README.md` becomes the homepage, documentation in `man/` generates a
function reference, and vignettes will be rendered into `articles/`.
Read `vignette("pkgdown")` for more details, and to learn how to deploy
your site to GitHub pages.
This adds the necessary components and sets up GitHub Actions for
automatic site building when deploying. Your `README.md` becomes the
homepage, documentation in `man/` generates a function reference, and
vignettes will be rendered into `articles/`. [^1]

### pkgdown 2.0.0 and Bootstrap 5

Expand Down Expand Up @@ -114,3 +107,6 @@ new pkgdown techniques.
Please note that this project is released with a [Contributor Code of
Conduct](https://pkgdown.r-lib.org/CODE_OF_CONDUCT.html). By
participating in this project you agree to abide by its terms.

[^1]: If you don’t use GitHub, you can use `usethis::use_pkgdown()` +
`pkgdown::build_site()` to create a website.
2 changes: 1 addition & 1 deletion man/init_site.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions vignettes/pkgdown.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ vignette: >
---

The goal of pkgdown is to make it easy to make an elegant and useful package website with a minimum of work.
You can get a basic website up and running in just a couple of minutes:
You can get a basic website up and running in just a couple of minutes. If you're using GitHub, we recommend setting up pkgdown and GitHub actions to automatically build and publish your site:

```{r, eval = FALSE}
# Run once to configure package to use pkgdown
usethis::use_pkgdown()
# Run to build the website
pkgdown::build_site()
# Run this once to publish your site regularly
usethis::use_pkgdown_github_pages()
```

If you're using GitHub, we also recommend setting up GitHub actions to automatically build and publish your site:
If you are not using GitHub, you will have to run `pkgdown::build_site()` manually everytime you want to update the site.

```{r, eval = FALSE}
usethis::use_pkgdown_github_pages()
# Run once
# Remove docs/ from gitignore to ensure it is checked into git.
usethis::use_pkgdown()
# Run everytime you want to update your site
pkgdown::build_site()
```


While you'll get a decent website without any additional work, if you want a website that really pops, you'll need to read the rest of this vignette.
It starts by showing you how to configure pkgdown with a `_pkgdown.yml`.
You'll learn about the main components of the site (the home page, reference, articles, and news), and then how to publish and promote your site.
Expand Down Expand Up @@ -118,8 +121,7 @@ It is recommended to name your intro article with your package name to generate
Due to the way that pkgdown has to integrate R Markdown generated HTML with its own HTML, relatively little control is available over the output format.
You can see the details in `?build_articles`.

If you want to include an article on the website but not in the package (e.g., because it's large), you can either place it in a subdirectory of `vignettes/` (e.g. `vignettes/web_only`) or add it to `.Rbuildignore` (and make sure that there's no `vignettes:` section in the yaml header). See `usethis::use_article()` for an automated way to do this.
In the extreme case where you want to produce only articles but not vignettes, you should add the complete `vignettes/` directory to `.Rbuildignore` and ensure that DESCRIPTION does not have a `VignetteBuilder` field.
If you want to include an [article](https://r-pkgs.org/website.html#non-vignette-articles) on the website but not in the package (e.g., because it's large), you can use `usethis::use_article()` to set it up.

## News

Expand Down Expand Up @@ -147,10 +149,9 @@ See `?build_news` for more customisation options including how to:

## Publishing

If you use GitHub, there are two ways to publish your site on GitHub Pages:

- Use GitHub actions to automatically build and publish the site every time you make a change.
The easiest way to set this up is to run `usethis::use_pkgdown_github_pages()`, and if you need to customize the action, see [README.md r-lib/actions](https://github.com/r-lib/actions/tree/v2-branch/examples#build-pkgdown-site).
If you use GitHub, the easiest way to build and publish your site is via GitHub actions.
Using GitHub actions automatically builds and publishes the site every time you make a change.
The easiest way to set this up is to run `usethis::use_pkgdown_github_pages()`, and if you need to customize the action, see [README.md r-lib/actions](https://github.com/r-lib/actions/tree/v2-branch/examples#build-pkgdown-site).

## Promoting

Expand Down

0 comments on commit c2a6389

Please sign in to comment.