When the source code is on GitLab, the generated web page gives the wrong link
Problem description
ecce package source code repo: https://gitlab.com/chuxinyuan/ecce
when I run pkgdown::build_news() or pkgdown::build_reference(), the link that appears on the webpage is: https://gitlab.com/chuxinyuan/ecce/-/
In fact, all of link about repo link on the page is wrong.
System environment
xfun::session_info("pkgdown")
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.3 LTS
#>
#> Locale:
#> LC_CTYPE=zh_CN.UTF-8 LC_NUMERIC=C
#> LC_TIME=zh_CN.UTF-8 LC_COLLATE=zh_CN.UTF-8
#> LC_MONETARY=zh_CN.UTF-8 LC_MESSAGES=zh_CN.UTF-8
#> LC_PAPER=zh_CN.UTF-8 LC_NAME=C
#> LC_ADDRESS=C LC_TELEPHONE=C
#> LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C
#>
#> Package version:
#> askpass_1.1 base64enc_0.1.3 brio_1.1.3 bslib_0.3.1
#> cachem_1.0.6 callr_3.7.0 cli_3.1.0 cpp11_0.4.2
#> crayon_1.4.2 curl_4.3.2 desc_1.4.0 digest_0.6.29
#> downlit_0.4.0 ellipsis_0.3.2 evaluate_0.14 fansi_1.0.0
#> fastmap_1.1.0 fs_1.5.2 glue_1.6.0 graphics_4.1.2
#> grDevices_4.1.2 highr_0.9 htmltools_0.5.2 httr_1.4.2
#> jquerylib_0.1.4 jsonlite_1.7.2 knitr_1.37 lifecycle_1.0.1
#> magrittr_2.0.1 memoise_2.0.1 methods_4.1.2 mime_0.12
#> openssl_1.4.6 pillar_1.6.4 pkgconfig_2.0.3 pkgdown_2.0.2
#> processx_3.5.2 ps_1.6.0 purrr_0.3.4 R6_2.5.1
#> ragg_1.2.1 rappdirs_0.3.3 rlang_0.4.12 rmarkdown_2.11
#> rprojroot_2.0.2 sass_0.4.0 stats_4.1.2 stringi_1.7.6
#> stringr_1.4.0 sys_3.4 systemfonts_1.0.3 textshaping_0.3.6
#> tibble_3.1.6 tinytex_0.36 tools_4.1.2 utf8_1.2.2
#> utils_4.1.2 vctrs_0.3.8 whisker_0.4 withr_2.4.3
#> xfun_0.29 xml2_1.3.3 yaml_2.2.1
Created on 2022-01-15 by the reprex package (v2.0.1)
Thanks for the bug report!
What link do you mean i.e. where is that wrong link on the webpage?
The assumption in pkgdown code is that BugReports beats the URL field, and then from BugReports the "issues" part is removed to create the repo URL.
https://github.com/r-lib/pkgdown/blob/6a412e3a9d2d12d43e6b24eb25b97633ec350cda/R/repo.R#L67-L69
This assumption does not work for GitLab repos, then. Do all GitLab repos issue trackers have repo URL + -/issues as URL?
In the meantime before a fix, you can use the repo field in the pkgdown configuration, if I'm not mistaken (but since I'm not exactly sure what URL on the webpage you mean, I was not able to check my assumption)
url: https://cxy.rbind.io/ecce/
repo:
url:
home: https://gitlab.com/chuxinyuan/ecce
source: https://gitlab.com/chuxinyuan/ecce/-/tree/master
(the url one is not needed for this but a good idea to add once your site is online).
@maelle Thank you for your concern and advice.
To ensure that ecce package users can find the repository address of the source code correctly, I had to manually correct it, So you see in https://cxy.rbind.io/ecce/ is the right result.
You can reproduce my results with pkgdown::build_site(). The error occurred at the following location:
- GitLab logo in the upper right corner on all pages.
- On the far right, Browse source code under Links
Ok, thanks for your patience, so I can reproduce the problem indeed, and if I add the file _pkgdown.yml with contents
url: https://cxy.rbind.io/ecce/
repo:
url:
home: https://gitlab.com/chuxinyuan/ecce
source: https://gitlab.com/chuxinyuan/ecce/-/tree/master/
the links are ok. So this configuration file would be a workaround.
Now regarding fixing pkgdown code itself, can you confirm that all GitLab repos issue trackers have repo URL + -/issues as URL? Thank you!
Yeah, this is kind of a temporary solution, in fact the DESCRIPTION file gives enough information. Should we consider taking advantage of it?
Now regarding fixing pkgdown code itself, can you confirm that all GitLab repos issue trackers have repo URL + -/issues as URL?
The BugReports address about ecce package I submitted to CRAN earlier is https://gitlab.com/chuxinyuan/ecce/issues, It can indeed be accessed, the pkgdown generated links are also fine.
But the official email from CRAN asked me to change it as prompted https://gitlab.com/chuxinyuan/ecce/-/issues, This is where the problem arises.
According to the BugReports field get the source code repo address is right way, but the address of GitLab issues has changed.
Yeah, this is kind of a temporary solution, in fact the DESCRIPTION file gives enough information. Should we consider taking advantage of it?
Yes this is a temporary workaround until there's a fix in pkgdown itself :-)
See #2018 (for now I'd trust the workaround more than my PR!)
See #2018 (for now I'd trust the workaround more than my PR!)
The code I have tested, very robust! Thank you very much for your efforts!
I think the problem is that you use https://gitlab.com/chuxinyuan/ecce/-/issues for BugReports instead of https://gitlab.com/chuxinyuan/ecce/issues, which works, and is what pkgdown expects.
What does the - in the url mean?
What does the - in the url mean?
n fact, I feel the - in url is redundant.
@chuxinyuan can you confirm there's nothing to fix then? :smile_cat:
I think the problem is that you use
https://gitlab.com/chuxinyuan/ecce/-/issuesfor BugReports instead ofhttps://gitlab.com/chuxinyuan/ecce/issues, which works, and is what pkgdown expects.
I believe that @chuxinyuan uses the first link because it is the one by default in GitLab
Therefore, this is yet a (potential) issue for many packages, making their webpages with broken links. You should expect the Bug report URL, when on GitLab, can be given with or without /- before /issues
I believe that @chuxinyuan uses the first link because it is the one by default in GitLab
Yes, I have no choice, because CRAN asked me to use the first link, although I prefer at https://gitlab.com/chuxinyuan/ecce/issues
@chuxinyuan : I imagine they ask for that because the shorter URL redirects to the longer one. CRAN doesn't like redirects because they sometimes indicate that a web site has moved, and the redirect will only be supported for a limited time.
@dmurdoch The key is that CRAN is audited in accordance with established procedures rather than human audit, so firm and uniform rules are necessary.