rgithubpackagepkgdown

Unable to push Package Website (pkgdown from R) to GitHub


I used the pkgdown package to create a new website of my package that will be hosted on Github.
I ran the following codes:

# Run once to configure package to use pkgdown
usethis::use_pkgdown()
# Run to build the website
pkgdown::build_site()

The function pkgdown::build_site has generated a subfolder docs\ in my local repo. You can see in the photo below (red arrow). And I need to push this docs\ subfolder to my Git repo, but I don't know why the docs\ subfolder does not show on my Git commit panel. So now I cannot push my website on GitHub.
enter image description here

Can someone help me spot out what's wrong? And how to fix this?
I have installed the pkgdown package using this command:

install.packages("pkgdown")

However, I was unable to install the development version for GitHub. Is it the reason?? I've tried to install but there're errors showed below:

# Install development version from GitHub
devtools::install_github("hadley/pkgdown")

##  ERROR: package installation failed
## Error: Failed to install 'pkgdown' from GitHub:
##   System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last ## 10 lines):
## E> ** inst
## E> ** byte-compile and prepare package for lazy loading
## E> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
## E>   namespace 'rlang' 0.4.10 is being loaded, but >= 0.99.0.9000 is required
## E> Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
## E> Execution halted
## E> ERROR: lazy loading failed for package 'pkgdown'
## E> * removing ## 'C:/Users/dokha/AppData/Local/Temp/Rtmpq0XtDc/Rinst212472df268f/pkgdown'
## E>       -----------------------------------
## E> ERROR: package installation failed
## In addition: There were 12 warnings (use warnings() to see them)

Solution

  • For reasons I don't totally understand, by default use_pkgdown() adds the docs/ folder to the .gitignore file. That's why it's not showing up in your commit panel. Open up the .gitignore file and delete the reference to docs (should be at the bottom), the docs folder should now appear in your .gitignore and you can commit and push it to your repo.

    Perhaps someone from pkgdown can explain why the docs folder is ignored when the instructions say to use it as the GitHub pages source?

    > usethis::use_pkgdown()
    ✓ Setting active project to '/Users/danovan/packages/marlin'
    ✓ Adding '^_pkgdown\\.yml$', '^docs$' to '.Rbuildignore'
    ✓ Adding '^pkgdown$' to '.Rbuildignore'
    ✓ Adding 'docs' to '.gitignore'