Skip to content

Make relativeURLs work for urls inside css file or <style> #4355

@apporc

Description

@apporc

Currenctly, relativeURLs only process those urls specified as href, for urls inside a style tag, it doesn't work.

For example

<style>
  @font-face {
    font-family: 'Icon';
    src: url('{{ "./fonts/icon.eot"}}');
  }
</style>

This tag is coded like that in an html file, which will be included in many other htmls.
Now in every html file, it is always './fonts/icon.eot', but there are cases it should be '../fonts/icon.eot' or '../../fonts/icon.eot'.

It seems like others have submitted issues similar. Let me clarify why this feature is needed, it's just like the href tag case.

I am hosting my same site code on many different production environment, and they may have different root. As in a environment A, the hugo site will be visited under http://example.com/, but in environment B, it is visited under http://example.com/hugo. As you can see, i can't use '/fonts/icon.eot' because the root is different.

This example what i extracted from ipfs static blog site. I want to visit my site from https://ipfs.io/ipns/... or a web hosting of mine with http://example.com/. Hope you understand now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions