# CSS links without hostname

**URL:** <https://forum.getkirby.com/t/css-links-without-hostname/11826>\
**Category:** Questions\
**Tags:** v2\
**Created:** [December 13, 2018, 1:17pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826 "2018-12-13T13:17:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrunkel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrunkel/32/4646_2.png) [@mrunkel](https://forum.getkirby.com/u/mrunkel)\
**Post date:** [December 13, 2018, 1:17pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/1 "2018-12-13T13:17:27Z")

</div>

Hey a question. Today I noticed that the css method generates links with the hostname and protocol attached.

This is a PITA for us because occasionally we want to proxy content (for example using ngrok for demos).

So my questions are why is Kirby forcing an absolute URL here? In general root-relative links are preferred are they not?

Any chance of making this a feature request? (The ability to prefer root-relative links?)

Thanks,

m.

P.S. I’m aware I can override the functionality and am already doing it with the kirby-sri module, but I’m curious why this decision was made.

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [December 13, 2018, 1:33pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/2 "2018-12-13T13:33:00Z")

</div>

I asked the same question some months ago, and the upshot is that relative links are bad for SEO. I asked from the perspective of making the HTML smaller, since the full address is taking up extra bytes. I’ve not run into issues with proxies, though, I’ve used NGROK and Browsersync proxies just fine.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 13, 2018, 1:37pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/3 "2018-12-13T13:37:00Z")

</div>

> **[Absolute vs Relative Path - Which Should You Be Using? - KeyCDN](https://www.keycdn.com/blog/relative-path)**
>
> Learn more about the differences that exist between an absolute and relative path. This article explains which method you should use and why.

---

<div class="post-metadata">

**Author:** ![mrunkel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrunkel/32/4646_2.png) [@mrunkel](https://forum.getkirby.com/u/mrunkel)\
**Post date:** [December 13, 2018, 2:29pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/4 "2018-12-13T14:29:51Z")

</div>

I read that article and to say it’s arguments are underwhelming is an understatement.

> If parts of your staging site are publicly accessible, it’s very important to avoid using relative URLs for your site navigation links. If a single incorrect link gets deployed to production, then it may open up your entire staging site to being crawled, indexed and displayed in search results. Having multiple copies of your website floating around in the search results can pose a serious security threat on top of duplicate content issues.

This doesn’t make any sense. This is ONLY a risk if you use absolute links. If you use relative links, your staging site is never exposed if the ‘wrong’ link gets into production, since the hostname **isn’t** in the link.

@jimbobrjames, we’re trying to load our site from a local dev environment via ngrok on a mobile device. Since the mobile device only has access to the content through the ngrok tunnel, it can’t load the CSS which is being served from the local device name and not the ngrok tunnel name.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 13, 2018, 2:54pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/5 "2018-12-13T14:54:20Z")

</div>

This is another argument I’ve found:

> If you have all of your internal links as relative URLs, it would be very, very, very easy for a scraper to simply scrape your whole website and put it up on a new domain, and the whole website would just work. That sucks for you, and it’s great for that scraper. But unless you are out there doing public services for scrapers, for some reason, that’s probably not something that you want happening with your beautiful, hardworking, handcrafted website. That’s one reason. There is a scraper risk.  
> ([https://moz.com/blog/relative-vs-absolute-urls-whiteboard-friday](https://moz.com/blog/relative-vs-absolute-urls-whiteboard-friday))

---

<div class="post-metadata">

**Author:** ![mrunkel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrunkel/32/4646_2.png) [@mrunkel](https://forum.getkirby.com/u/mrunkel)\
**Post date:** [December 13, 2018, 3:23pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/6 "2018-12-13T15:23:11Z")

</div>

Soo… Somebody spends the time to scrape your entire site but then can be bothered to just replace the URLs?

I not sure this is much of an argument. 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 13, 2018, 3:42pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/7 "2018-12-13T15:42:46Z")

</div>

I just posted what I’ve read in the past. You can create a feature request on GitHub or just not use the functions provided by Kirby.

Does this just affect the CSS/JS methods or also images?

Wondering whether this could be solved with a config setting that set’s the url to your ngrok url when using ngrok via a multi-environment setup, haven’t tested this.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [December 14, 2018, 12:17pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/8 "2018-12-14T12:17:15Z")

</div>

You can configure Kirby to use domain-relative URLs like so:

```php
c::set('url', '/');

```

---

<div class="post-metadata">

**Author:** ![mrunkel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrunkel/32/4646_2.png) [@mrunkel](https://forum.getkirby.com/u/mrunkel)\
**Post date:** [December 14, 2018, 1:18pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/9 "2018-12-14T13:18:48Z")

</div>

Doh. Of course that’s the right solution. 🙂

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:25pm UTC](https://forum.getkirby.com/t/css-links-without-hostname/11826/10 "2025-02-06T17:25:39Z")

</div>

Archived on February 6, 2025, 5:25pm UTC


