diff --git a/NEWS.md b/NEWS.md index eb4f44181..ace981f0c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # pkgdown (development version) +* `build_home()` no longer uses (unrendered) `README.Rmd` or `index.Rmd` if + corresponding `.md` files are not found. + * You can have much richer control over Open Graph and Twitter metadata for the site as the whole, and for individual articles. See `vignette("metadata")` for details (@gadenbuie, #936). @@ -27,8 +30,8 @@ * pkgdown now uses the ORCiD logo included in Font Awesome 5.11 instead of querying it from members.orcid.org (@bisaloo, #1153) -* `build_home()` now looks for `pkgdown/index.md` and `pkgdown/index.Rmd` in - addition to the top-level `index` or `README` files (@nteetor, #1184) +* `build_home()` now looks for `pkgdown/index.md` in addition to the top-level + `index` or `README` files (@nteetor, #1031) * New `deploy_to_branch()` function to build and deploy a site to a branch, defaulting to `gh-pages` to use with GitHub Pages. (@jimhester, #1221) @@ -63,9 +66,9 @@ library, and runs examples/articles in a new process. * `build_reference()` no longer runs `devtools::document()` (#1079) and - `build_home()` no longer re-builds `README.Rmd`. This makes the scope - of responsibility of pkgdown more clear: it now only creates/modifies - files in `doc/`. + `build_home()` no longer re-builds `README.Rmd` or `index.Rmd`. This makes + the scope of responsibility of pkgdown more clear: it now only + creates/modifies files in `doc/`. * `build_home()` now strips quotes from `Title` and `Description` fields when generating page metadata. Additionally, you can now override the diff --git a/R/build-home-index.R b/R/build-home-index.R index 12d60adb1..11facfcc5 100644 --- a/R/build-home-index.R +++ b/R/build-home-index.R @@ -7,11 +7,8 @@ build_home_index <- function(pkg = ".", quiet = TRUE) { src_path <- path_first_existing( pkg$src_path, c("pkgdown/index.md", - "pkgdown/index.Rmd", "index.md", - "README.md", - "index.Rmd", - "README.Rmd" + "README.md" ) ) dst_path <- path(pkg$dst_path, "index.html") diff --git a/R/build-home.R b/R/build-home.R index c4d3c157e..fe6ab283d 100644 --- a/R/build-home.R +++ b/R/build-home.R @@ -1,11 +1,20 @@ #' Build home section #' -#' This function generates the home page, and converts other `.md` files -#' typically found in the package root and in `.github/`. It generates the home -#' page from `index.md` or `README.md`, falling back to the description field -#' in `DESCRIPTION` if neither is found. It also builds an authors page -#' from the `DESCRIPTION` and `inst/CITATION` (if present) and -#' a license page, and converts any `.md` files found in +#' 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). +#' +#' @section 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. #' #' @section Sidebar: #' The sidebar is automatically populated with: diff --git a/man/build_home.Rd b/man/build_home.Rd index e40dbac71..6c05c62c6 100644 --- a/man/build_home.Rd +++ b/man/build_home.Rd @@ -19,13 +19,24 @@ freshly generated section in browser.} pandoc. This is useful when debugging.} } \description{ -This function generates the home page, and converts other \code{.md} files -typically found in the package root and in \verb{.github/}. It generates the home -page from \code{index.md} or \code{README.md}, falling back to the description field -in \code{DESCRIPTION} if neither is found. It also builds an authors page -from the \code{DESCRIPTION} and \code{inst/CITATION} (if present) and -a license page, and converts any \code{.md} files found in +This function generates the home page, converts \code{.md} files found in the +package root (and in \verb{.github/}), and builds an authors page from +\code{DESCRIPTION} and \code{inst/CITATION} (if present). } +\section{Home page}{ + +The home page (\code{index.html}) is generated from \verb{_pkgdown/index.md}, +\code{index.md}, or \code{README.md}, in that order. Most packages will use \code{README.md} +because that's also displayed by GitHub and CRAN. Use \code{index.md} if you want +your package website to look different to your README, and use +\verb{_pkgdown/index.md} if you don't want that file to live in your package +root directory. + +If you use \code{index.Rmd} or \code{README.Rmd} it's your responsibility to knit +the document to create the corresponding \code{.md}. pkgdown does not do this +for you because it only touches files in the \verb{doc/} directory. +} + \section{Sidebar}{ The sidebar is automatically populated with: