Multi-Site - cannot site specific CSS

Greetings.

So I have set up a multi-site system as per the DOCs.

Everything works (panel included).

I modified the INDEX.PHP to include the ā€˜assetsā€™ files in the multi-site set up.

'assets' => $root . '/assets'

However, no matter what I try, the CSS will not load.

The CSS will only load if it in the root assets folder.

This is obviously not what I intended since every different site has different CSS/Layout/etc for the same pages (home.php, about.php).

Any ideas on this?

Whilst I canā€™t see the changes in your index.php you were referring to; it might have to do something with paths not properly setup. AFAIK you shouldnā€™t tamper with setting up the path to the assets folder by hand; thereā€™s a helper for that.

More info: https://getkirby.com/docs/reference/system/roots/assets

Yes, sorry ā€¦ didnā€™t want to dump a lot of code if I didnā€™t have to.

Here is my full index.php ā€¦

<?php
require 'kirby/bootstrap.php';

$sites = [
      'localhost' => __DIR__ . '/'
  ,   'siteA.local' => __DIR__ . '/subs/subdomain01/siteA'
];

$url  = Url::host();
$root = $sites[$url];

$kirby = new Kirby([
  'roots' => [
        'index'   => $root
    ,   'assets'  => $root . '/assets'
    ,   'config'  => $root . '/config'
    ,   'content' => $root . '/content'
    ,   'media'   => $root . '/media'
    ,   'site'    => $root . '/site'
  ]
]);

echo $kirby->render();

My directories are set up as per the standard vanilla install of Kirby and the extra subs directory. The directories are as you would expect underneath (sites has templates, blueprints).

subs
    subdomain01
        siteA
            assets
                css
                    templates
            content
            media
            site

Do your other assets work as expected. Is it just the template specific ones that donā€™t?

$sites is defined in the above index.php

1 Like

@texnixe - I am only just starting to learn/piece together Kirby 3 and so as a designer I jumped to the CSS first.

The panel works without a problem for all subsites that I have created. The INDEX.PHP above is what I am currently working with just for test, but I had 8 subsites running with the panel at one stage.

It was when I then turned to doing a basic CSS for each of the sites that I ran into this problem.

Hm, Iā€™m not sure that answers my question. What is in your assets/css/templates folder? Did you reference these files in your header using the @auto method?

Oh okay ā€¦ the following is the ā€œheaderā€ snippet that is being used to inject the CSS.

And the structure of the assets directory is as I showed above ā€¦ an exact copy of the sample kirby site with the magazine template.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><?= $site->title() ?> | <?= $page->title() ?></title>
  <?= css('@auto') ?>
</head>