Multi-Site - cannot site specific CSS


#1

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?


#2

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


#3

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

#4

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


#6

$sites is defined in the above index.php


#7

@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.


#8

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?


#9

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>