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

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

Open
apporc opened this issue Jan 30, 2018 · 7 comments
Open

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

apporc opened this issue Jan 30, 2018 · 7 comments

Comments

@apporc
Copy link

apporc commented Jan 30, 2018

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:https://example.com/, but in environment B, it is visited under http:https://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:https://example.com/. Hope you understand now.

@bep
Copy link
Member

bep commented Jan 30, 2018

This is a known limitation. Have you searched for a duplicate issue?

@apporc apporc changed the title relativeURLs should should transform for urls in css file/<style> tag too. relativeURLs should transform for urls in css file/<style> tag too. Jan 30, 2018
@apporc apporc changed the title relativeURLs should transform for urls in css file/<style> tag too. relativeURLs should work for urls inside css file or <style> tag too. Jan 30, 2018
@apporc
Copy link
Author

apporc commented Jan 30, 2018

Is this hard to implement, i have searched the code, got to transform/absurlreplacer.go, but i am not really familar with go.

@bep
Copy link
Member

bep commented Jan 30, 2018

Is this hard to implement

Yes it is.

I suggest you look for older threads and workarounds for this.

@apporc
Copy link
Author

apporc commented Jan 31, 2018

I searched again in the older threads, didn't find a workaround. But i thought out an ugly one for myself, to restrict all my production environment with the same root.

@bep bep changed the title relativeURLs should work for urls inside css file or <style> tag too. Make relativeURLs work for urls inside css file or <style> tag too. Jan 31, 2018
@bep bep changed the title Make relativeURLs work for urls inside css file or <style> tag too. Make relativeURLs work for urls inside css file or <style> Jan 31, 2018
@bep bep modified the milestones: v0.36, v0.37 Jan 31, 2018
@bep bep modified the milestones: v0.37, v0.38 Feb 11, 2018
@bep bep modified the milestones: v0.38, v0.39 Feb 21, 2018
@bep bep modified the milestones: v0.39, v0.40 Apr 9, 2018
@bep bep modified the milestones: v0.40, v0.41 Apr 20, 2018
@bep bep modified the milestones: v0.41, v0.42 May 4, 2018
@bep bep modified the milestones: v0.42, v0.43 Jun 5, 2018
@bep bep modified the milestones: v0.43, v0.44 Jun 30, 2018
@bep bep modified the milestones: v0.44, v0.45, v0.46 Jul 10, 2018
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
@bep bep modified the milestones: v0.129.0, v0.131.0 Jul 22, 2024
@bep bep modified the milestones: v0.131.0, v0.133.0 Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants