Skip to content

Missing / in resource url when previewing on Netlify #102

@cderv

Description

@cderv

When I deploy a branch preview on Netlify, the site using this theme does not look right because the CSS and JS resources from the theme are not found.

I believe this is because {{.Site.BaseURL}} is used, and it does not add missing trailing slash. I have one in my baseURL config but Netlify sets none when changing the base URL.

<link rel="stylesheet" href="{{ .Site.BaseURL }}dist/site.css">
<link rel="stylesheet" href="{{ .Site.BaseURL }}dist/syntax.css">

However, it seems that loading resource this way is not advice. See gohugoio/hugo#3262 (comment) where the maintainer of hugo advice the following

But manually creating URLs using {{ .Site.BaseURL }} is fragile, esp. for themes, and not recommended. Use absURL and friends, and you should not have to worry about slashes.

Using relURL or absURL would be better I believe.

This fix the issue I encounter if I tweak the theme. But there are a lot of occurrences in the theme of this.
I think this should be fixed as the theme level.

Does this cause any issue with anyone in the past ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions