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

Incorrect site root path for packages in dev status? #2814

Closed
jayhesselberth opened this issue Nov 9, 2024 · 3 comments
Closed

Incorrect site root path for packages in dev status? #2814

jayhesselberth opened this issue Nov 9, 2024 · 3 comments

Comments

@jayhesselberth
Copy link
Collaborator

jayhesselberth commented Nov 9, 2024

In trying to fix #2804, I think I uncovered a different issue. It doesn't look like the site root path is set correctly for packages in dev status.

The paths to the head assets (favicon, JS, CSS) in the template are specified like this:

<link rel="icon" type="image/png" sizes="16x16" href="{{#site}}{{root}}{{/site}}favicon-16x16.png">

BUT in a site in dev status (i.e., pkgdown), site.root is an empty string. I think it should actually be /dev/ or dev/.

Here's the relevant bit of pkgdown::data_template() run on current pkgdown:

site:
  root: ''
  title: pkgdown

So what ends up happening on a dev site is that the site is copied to /dev, but the href values in the site head don't have the /dev/ prefix.

I am guessing this has gone unnoticed because most packages start with a release version, where everything (assets and site) is copied to /. Then, in a subsequent dev version, the site contents are copied to /dev, but the assets are still in /, so the head href links still work, but they're using the assets from the released site in /.

This is also why the favicon checker is failing in #2804. The head of the deployed site has:

<link rel="icon" type="”image/svg+xml”" href="favicon.svg">

but the file is actually in /dev/favicon.svg (correct link). And the deployed site only has the stuff in /dev and can't rely on anything in /.

You can also see this in the dev pkgdown site. It's head has the following, so is using the favicon assets from the released site:

<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">

I think the fix is to make site.root mirror pkg$development$prefix (but with a leading slash, so /dev/ instead of dev/)

@jayhesselberth
Copy link
Collaborator Author

@hadley does the above make sense? I'm struggling to get the href paths right but I think the issue is real.

@hadley
Copy link
Member

hadley commented Nov 25, 2024

Yeah, I think that makes sense.

@jayhesselberth
Copy link
Collaborator Author

I'm closing this for now as this only impacts dev sites. It's also unclear how to specify the paths so that favicons work for non-root sites.

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

No branches or pull requests

2 participants