rstudio / pkgs.rstudio.com

https://pkgs.rstudio.com
1 stars 1 forks source link

Allow to add pkgdown website currently hosted in github pages #2

Open cderv opened 3 years ago

cderv commented 3 years ago

Note sure if this is already possible with the current mechanism of netlify redirect. I have in mind:

There may be others I don't think of right now.

apreshill commented 3 years ago

No this is not possible- the rewrites require us to have the existing sites published to Netlify in our same RStudio org. Folks can deploy to Netlify from gh-pages or master/docs though, then rewrite over that. We had discussed pkgdown deploying with some canonical URL metadata tag to help search engines prefer the pkgs.rstudio.com/ url and over time, the github.io url would hopefully be less prevalent in search results.

https://github.com/rstudio/pkgs.rstudio.com/blob/master/_redirects

cderv commented 3 years ago

Ok that is what I was so this would mean that if we want more packages to be listed, we would have to ask the different maintainers to switch over to a netlify deploy then. Is this planned ? Is it too soon ? It is a big limation of netlify for such a service as pkgs.rstudio.com aiming to list all packages. But it is also a good motivation to have all the pkgdown website in the same netlify.org.

Although you were mentionning having a specific netlify org for Rmarkdown related website: would this work ? Is it a suborganisation of rstudio org in Netlify ?

We had discussed pkgdown deploying with some canonical URL metadata tag to help search engines prefer the pkgs.rstudio.com/ url and over time, the github.io url would hopefully be less prevalent in search results.

What needs to be done for that ?

apreshill commented 3 years ago

A big limitation for sure. I'm not sure how best to handle this.

We had discussed leaving the GH pages version up in parallel with Netlify site for a period of time (potentially have the GH workflow deploy to branch + Netlify, but this may be silly?). This morning I was wondering if the actual Netlify deploy is needed- could we use the GH Pages deploy with a CNAME to pkgs.rstudio.com/pkgname in pkgdown- I don't know if this would work? The url field in _pkgdown.yaml should autogenerate the CNAME (https://pkgdown.r-lib.org/reference/build_site.html#yaml-config), but I don't know how Netlify will behave.

The canonical url was the idea Hadley suggested in one of our meetings to gracefully let the GH pages link stop appearing in search results, idea being at some point we do remove the GH pages deploy altogether. See: https://github.com/r-lib/pkgdown/issues/1527

yihui commented 3 years ago

For security reasons, rewrites between Netlify sites belonging to different teams are not allowed.

I don't know if the above Netlify documentation is up-to-date or accurate: https://docs.netlify.com/routing/redirects/rewrites-proxies/#limitations but I just tried two senarios in my own Netlify account and both worked fine.

First I tried this _redirects:

/*  https://pkgs.rstudio.com/rmarkdown/:splat  200!

It means redirecting a site from one Netlify team's account (mine) to another (RStudio's).

Then I tried:

/*  https://rstudio.github.io/renv/:splat  200!

It means redirecting from a Netlify site to Github Pages. It also worked fine: https://nervous-goldwasser-5f8295.netlify.app/

So it sounds like we could add this to the end of our _redirects so that pkgs.rstudio.com/foo/ could be rewritten to our Github Pages at rstudio.github.io/foo/.

/*  https://rstudio.github.io/:splat  200
cderv commented 3 years ago

Oh thanks! That is great news. Thanks for trying this.

The latter suggestion means we would not need to list every package then. 😄 This would be practical!

But I think we need to "register" the list for the homepage listing mainly. And also, adding this rule would mean that https://pkgs.rstudio.com/visual-markdown-editing/ would work! Do we want that ?

I think having a simple way to register a new package (like #3) would fit nicely, and it would cost nothing to write the netlify _redirect

yihui commented 3 years ago

And also, adding this rule would mean that https://pkgs.rstudio.com/visual-markdown-editing/ would work! Do we want that ?

Yes, it will work. The question is just which URL we'd want to advertise. I don't really have a preference.

I think having a simple way to register a new package (like #3) would fit nicely, and it would cost nothing to write the netlify _redirect

I don't have a preference. The _redirects file is simple and intuitive enough to me (only three columns). I feel using the yaml format will make it more complicated:

- pkg: foo
  url: http://example.com/foo
- pkg: bar
  url: http://example.com/bar

Not sure what the yaml format was like on your mind.

cderv commented 3 years ago

It would be this form yes. I thought it could make it simple for to add new registered package, but for a package maintainer, editing a _redirect could be as easy as you said.

cderv commented 3 years ago

@yihui I added the rule for generic redirect to rstudio.github.io and now I remember why this was not ok for us.

The redirects works, but the rewrite does not happen. And I think this is the limitation we had in mind with Alison: https://docs.netlify.com/routing/redirects/rewrites-proxies/#limitations

By setting the generic rule you mentioned above for rstudio.github.io I think we are using "Proxy to external service" feature from netlify: https://docs.netlify.com/routing/redirects/rewrites-proxies/#proxy-to-another-service, which is not a rewrite.

So having all the website on the same Netlify team is currently a requirement to have the rewrite working as expected it seems.

yihui commented 3 years ago

Yes, I was basically saying above that proxy to Github pages works fine, e.g., (gt is an exception so we need /gt/* https://gt.rstudio.com/:splat 200)

https://pkgs.rstudio.com/renv/ https://pkgs.rstudio.com/rstudioapi/

From my understanding, proxy is just a special case of rewrite. Regardless of whether my understanding is correct, users see the URLs pkgs.rstudio.com/* when the web pages actually served are from other websites. That's the goal that pkgs.rstudio.com tries to achieve, right? Or did I misunderstand it?

cderv commented 3 years ago

Oh I know what happened ! I got mixed up and bitten by another redirection mechanism.

I tried https://pkgs.rstudio.com/learnr (without trailing slash) which will redirect you to to https://rstudio.github.io/learnr/ changing the url in the browser window ! However, https://pkgs.rstudio.com/learnr/ (with a trailing slash) do the job as in your demo above. There is a rewrite indeed and the URL is still this one that the user sees and not https://rstudio.github.io/learnr/

So yes it works!

Sorry for the mixup. (@apreshill sorry for the confustion I may have put you in earlier!) That is really great news! I'll check this redirection stuff with trailing / later. This is exactly what we added in our quillt template using JS script.

Thank you @yihui for the clarification!