Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkgdown::deploy_to_branch creates malformed URLs #2816

Open
jwimberl opened this issue Nov 13, 2024 · 1 comment
Open

pkgdown::deploy_to_branch creates malformed URLs #2816

jwimberl opened this issue Nov 13, 2024 · 1 comment

Comments

@jwimberl
Copy link

The function pkgdown::deploy_to_branch modifes the URL provided by the user by extending it by the specified build subdirectory:

pkgdown/R/deploy-site.R

Lines 147 to 149 in c40ba2c

if (!is.null(subdir) && !is.null(pkg$meta$url)) {
pkg$meta$url <- path(pkg$meta$url, subdir)
}

When the URL starts with a protocol, as it should, the fs::path method will replace the double forward slash with a single one, turning a valid URL like https://www.hostname.org into http:/www.hostname.org.

I think the behavior of automatically appending the subdir argument to the URL is also an issue:

  • This equates the documented intent of subdir, a filesystem directory within the gh-pages branch in which the generated code tracked, with the URL location at which the documentation will be served. A user may very well want to keep the documentation in a docs/ subfolder in the gh-pages branch, but not serve the documentation at a URL that has to end in /docs/
  • This leads to inconsistent behavior with pkgdown::build_site(...) and other methods: a setting for url that works for one will generate incorrect absolute URLs with the other. I think there are various good reasons that the generated HTML and links should be identical whichever build method is used. For one, build_site(...) is useful for checking for issues before calling deploy_to_branch(...), since the latter makes a git commit before the generated HTML could be previewed.
@jayhesselberth
Copy link
Collaborator

jayhesselberth commented Nov 13, 2024

Hmm, we might use httr2::url_build() here instead.

httr2 is heavy-handed for this, but probably be shouldn't be using fs::path() for a URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants