# Multisite not loading CSS/assets?

**URL:** <https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953>\
**Category:** Questions\
**Tags:** v2\
**Created:** [July 12, 2017, 1:34pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953 "2017-07-12T13:34:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 12, 2017, 1:34pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/1 "2017-07-12T13:34:27Z")

</div>

Quick question, have been playing with multisite kirby with a single kirby/panel folder and the rest in sub folders of `websites/domain`. But no css is loading, it will if I put the assets folder in the root, but that defeats the object of having separate asset folders. It is like it is not picking up the path to assets. Anyone and ideas?

A picture might make it easier to visualise:

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/7/7f81bb22802e084ec66eae834d7c4a7d155126f3.png)

My site.php looks like this:

```php
<?php

// /site.php

$kirby = kirby();
$domain = server::get('server_name');
$domains = array('test.dev', 'test2.dev');

if(in_array($domain, $domains)) {

  // custom roots
  $kirby->roots->site = __DIR__. DS . 'websites'. DS . $domain . DS . 'site';
  $kirby->roots->content = __DIR__. DS . 'websites'. DS . $domain . DS . 'content';
  $kirby->roots->assets = __DIR__. DS . 'websites'. DS . $domain . DS . 'assets'; 
  $kirby->roots->avatars = __DIR__. DS . 'websites'. DS . $domain . DS . 'assets'. DS . 'avatars';
  $kirby->roots->thumbs = __DIR__. DS . 'websites'. DS . $domain . DS . 'thumbs';

  // custom urls
  
  $kirby->urls->index = url::scheme() . '://' . $domain;	
  $kirby->urls->content = $kirby->urls->index . DS . 'websites'. DS . $domain . DS . 'content/';
  $kirby->urls->assets = $kirby->urls->index . DS . 'websites'. DS . $domain . DS . 'assets';
  $kirby->urls->avatars = $kirby->urls->index . DS . 'websites'. DS . $domain . DS . 'assets/avatars/';
  $kirby->urls->thumbs = $kirby->urls->index . DS . 'websites'. DS . $domain . DS . 'thumbs/';

}

```

---

<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:** [July 12, 2017, 1:38pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/2 "2017-07-12T13:38:00Z")

</div>

What does it actually output as the path to the assets?

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 12, 2017, 1:48pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/3 "2017-07-12T13:48:13Z")

</div>

OK, if I echo:  
` __DIR__. DS . 'websites'. DS . $domain . DS . 'assets';`  
I get:  
`/Users/russellbaldwin/Sites/multisite/websites/test.dev/assets`  
Which on a Mac looks OK?

And if I echo:  
`$kirby->urls->index . DS . 'websites'. DS . $domain . DS . 'assets'`  
I get:  
`/websites/test.dev/assets`  
Which also looks OK?

Can I provide any more info, a bit baffled.

---

<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:** [July 12, 2017, 1:50pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/4 "2017-07-12T13:50:35Z")

</div>

What I actually wanted to know was what the css helper actually renders in the page:

```auto
<?= css('assets/css/whatever.css'); ?>

```

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 12, 2017, 1:53pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/5 "2017-07-12T13:53:05Z")

</div>

Apologies Sonja, I misunderstood :

For test.dev:  
`<link rel="stylesheet" href="http://test.dev/assets/css/index.css">`

For test2.dev:  
`<link rel="stylesheet" href="http://test2.dev/assets/css/index.css">`

---

<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:** [July 12, 2017, 1:57pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/6 "2017-07-12T13:57:15Z")

</div>

Thanks, Russ, I’ll look into this as soon as I can.

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 12, 2017, 1:59pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/7 "2017-07-12T13:59:55Z")

</div>

Thanks Sonja, if you need anymore information let me know. It seems like it is not picking up the assets path from the site.php, of course it might not be picking up other stuff as well, but that is as far as I have got. Hopefully you will be able to reproduce it.

Russ

---

<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:** [July 12, 2017, 2:56pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/8 "2017-07-12T14:56:11Z")

</div>

Does it render anything on the page with this setup?

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 12, 2017, 3:07pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/9 "2017-07-12T15:07:48Z")

</div>

As far as I can see all of the home page minus the CSS, same for About and Contact. Projects loads, but clicking ‘Project A’ gives an error `file_get_contents(): Filename cannot be empty`

`Whoops\Exception\ErrorException /vendor/getkirby/toolkit/lib/media.php166`

This is the same error for ‘Blog’.

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 12, 2017, 3:10pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/10 "2017-07-12T15:10:10Z")

</div>

This is on Kirby Version 2.5.2 starter kit, downloaded today.

If I move the assets folder from one of the sites to the root, all pages work as expected.

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 16, 2017, 3:42pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/11 "2017-07-16T15:42:46Z")

</div>

Just wondering if you have had any thoughts on this yet Sonja?

---

<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:** [July 16, 2017, 3:46pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/12 "2017-07-16T15:46:08Z")

</div>

Hey Russ,

sorry, unfortunately, it slipped my mind after I got frustrated with being unable to get this setup to work at all for testing…

Maybe @lukasbestle can come to the rescue?

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 16, 2017, 3:53pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/13 "2017-07-16T15:53:41Z")

</div>

Thanks Sonja, maybe this can help, a link [my test setup in a zip](http://downloads.shoesforindustry.net/).  
I’ve added an ‘\_assets’ file in the multisite root. Rename this and it all seems to work OK. Remove that file and even though the assets exist in the individual site folders, it does not seem able to find assets.

---

<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:** [July 16, 2017, 4:37pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/14 "2017-07-16T16:37:10Z")

</div>

Thanks for the zip. Unfortunately, I get the same result and no idea how to fix it 😢

---

<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:** [July 16, 2017, 6:17pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/15 "2017-07-16T18:17:15Z")

</div>

I see two issues:

1. You are using `DS` in the URLs. This will work on all systems that use forward-slashes as directory separators, but not on Windows for example. Please use a simple `/` there. Of course you should still use `DS` for the roots.
2. The `$kirby->urls->assets` is only used for the `autocss`/`autojs` feature and the `avatars`, not for simple executions of the `css()`/`js()` helpers. You need to prefix those manually or change your setup so that the assets are accessible from the URLs based on the domain root. Best way would be to point your web server at the `websites/<domain>` directories directly. Your `index.php` in those directories could then init some shared code like a global `kirby` directory.

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 17, 2017, 6:58am UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/16 "2017-07-17T06:58:35Z")

</div>

Hi Lukas, thanks for taking a look but I’m not sure I understand what you are saying.

1. Are you saying it does not work as I have it laid out? Can we have a shared kirby/panel (and maybe other e.g. plugins) folder with sub folders for domains. I was pointing the domains at the multisite folder/site.php and thinking that would point to sub folders, am I wrong?
2. On both Unix or MacOS it is the same. Changing to ‘/’ alters nothing but I appreciate your point. The CSS and JS are loaded by autocss/autojs as they are the starter kit files. I’m also a bit confused about this, does this mean the ‘asset path’ cannot be used for images/fonts? Perhaps you have to set it manually in site.php?

Sorry if I’m not being very clear, hope you can help.

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 18, 2017, 2:38pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/17 "2017-07-18T14:38:10Z")

</div>

Anyone any thoughts? I’d really like to get this to work.

---

<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:** [July 19, 2017, 6:40pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/18 "2017-07-19T18:40:31Z")

</div>

Sorry for the delay!

> [@AudioBear](#):
>
> Are you saying it does not work as I have it laid out? Can we have a shared kirby/panel (and maybe other e.g. plugins) folder with sub folders for domains. I was pointing the domains at the multisite folder/site.php and thinking that would point to sub folders, am I wrong?

Your setup _will_ work, but not exactly in the way you implemented it.  
My recommendation: Use a directory structure like this:

```auto
kirby/
  ...
panel/
  ...
test.dev/
  assets/
    ...
  content/
    ...
  index.php
  kirby -> ../kirby
  panel -> ../panel
  site/
    ...
test2.dev/
  assets/
    ...
  content/
    ...
  index.php
  kirby -> ../kirby
  panel -> ../panel
  site/
    ...

```

Basically you have separate sites but use a global `kirby` and `panel` directory outside of the webroots. Those two directories are then linked into the sites using a symbolic link (`ln -s ../kirby kirby`).

> [@AudioBear](#):
>
> On both Unix or MacOS it is the same. Changing to ‘/’ alters nothing but I appreciate your point.

It won’t change anything on Linux/macOS. But you should change it anyway. 🙂

> [@AudioBear](#):
>
> The CSS and JS are loaded by autocss/autojs as they are the starter kit files. I’m also a bit confused about this, does this mean the ‘asset path’ cannot be used for images/fonts? Perhaps you have to set it manually in site.php?

Kirby does not keep track of any other assets than `autocss`/`autojs` and avatars. It just doesn’t care at all where all other assets like images and fonts are stored. That’s why there is no configuration option for this – it wouldn’t get used anywhere.  
If you use `css('assets/css/whatever.css')`, you just get a style tag with a URL that is relative to the site’s root URL, it doesn’t matter if you are pointing to the `assets` directory or a directory with a different name.

---

<div class="post-metadata">

**Author:** ![AudioBear](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/audiobear/32/315_2.png) [@AudioBear](https://forum.getkirby.com/u/AudioBear)\
**Post date:** [July 20, 2017, 10:51am UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/19 "2017-07-20T10:51:27Z")

</div>

Thanks for all you help and explanations Lukas, it is appreciated.

I tried as you suggest with an alias back to the kirby and panel folders in multisite. (I moved the websites sub folder to the root.)

```
multisite
├── index.php
├── kirby
├── panel
├── site.php
├── test.dev
    ├── assets
    ├── content
    ├── index.php
    ├── kirby -> ../kirby
    ├── panel -> ../panel
    ├── site
    └── thumbs
└── test2.dev
    ├── assets
    ├── content
    ├── index.php
    ├── kirby -> ../kirby
    ├── panel -> ../panel
    ├── site
    └── thumbs

```

1. If I point test.dev domain to where the real Kirby/Panel/site.php (multisite folder) I still get no CSS loading.
2. If I point the test.dev domain to it’s actual folder (multisite/test.dev/) I get an error **Fatal error** : The site directory is missing in **/xxx/xxx/Sites/multisite/kirby/kirby.php** on line **536**

Any ideas?

---

<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:** [July 21, 2017, 2:42pm UTC](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953/20 "2017-07-21T14:42:18Z")

</div>

- You should delete the `index.php` and `site.php` in the `multisite` directory. Those aren’t required for your setup.
- Please point the server at the site’s subdirectories directly.

> [@AudioBear](#):
>
> Fatal error: The site directory is missing in /xxx/xxx/Sites/multisite/kirby/kirby.php on line 536

Oops, I forgot something. Please create a `multisite/test.dev/site.php` with the following contents:

```php
<?php

$kirby = kirby();
$kirby->roots = new Kirby\Roots( __DIR__ );

```

[Next page](https://forum.getkirby.com/t/multisite-not-loading-css-assets/7953.md?page=2)
