Skip to content

Fix relURL for custom_css#252

Merged
regisphilibert merged 1 commit intotheNewDynamic:masterfrom
nickjwhite:customcss
Jun 3, 2020
Merged

Fix relURL for custom_css#252
regisphilibert merged 1 commit intotheNewDynamic:masterfrom
nickjwhite:customcss

Conversation

@nickjwhite
Copy link
Contributor

The way relURL was used meant that one needed to preface the custom_css
entries with a slash, or the href would be incorrectly set to
subdircss/mycss.css rather than subdir/css/mycss.css, in the case of
a baseURL in a subdir.

The way relURL was used meant that one needed to preface the custom_css
entries with a slash, or the href would be incorrectly set to
subdircss/mycss.css rather than subdir/css/mycss.css, in the case of
a baseURL in a subdir.
@regisphilibert regisphilibert self-requested a review February 5, 2020 20:37

{{ range .Site.Params.custom_css }}
<link rel="stylesheet" href="{{ relURL ($.Site.BaseURL) }}{{ . }}">
<link rel="stylesheet" href="{{ relURL (.) }}">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickjwhite thank you for this.

Would you mind removing the () while you're at it. I understand they were there initially, but it turns out they're not needed.

<link rel="stylesheet" href="{{ relURL . }}">

This reads a bit picky, but we're getting back at improving the theme and use it to promote Hugo's best practices.


{{ range .Site.Params.custom_css }}
<link rel="stylesheet" href="{{ relURL ($.Site.BaseURL) }}{{ . }}">
<link rel="stylesheet" href="{{ relURL (.) }}">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For your convenience:

Suggested change
<link rel="stylesheet" href="{{ relURL (.) }}">
<link rel="stylesheet" href="{{ relURL . }}">

I hope that makes it easier to fix!

@regisphilibert
Copy link
Member

@jan-xyz sorry for merging this so late! Thanks!

@regisphilibert regisphilibert merged commit cfbd40c into theNewDynamic:master Jun 3, 2020
Remicck pushed a commit to Remicck/gohugo-theme-ananke that referenced this pull request Mar 7, 2022
The way relURL was used meant that one needed to preface the custom_css
entries with a slash, or the href would be incorrectly set to
subdircss/mycss.css rather than subdir/css/mycss.css, in the case of
a baseURL in a subdir.

Co-authored-by: Nick White <git@njw.name>
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

Successfully merging this pull request may close these issues.

3 participants