Theme structure for Grav Multisite, how do I have subdirectory use main theme

I’m trying to get a website running locally with multisite. It works properly already as signle site. I’m using Multisite Setup | Grav Documentation as a guide. The goal is to have the subdirectory site inherit theme, but have different page content, so we only need to track it’s differences from the main site. (mainly different pages, same theme). Lastly, the one requirement is no symlinks, it would be great to achieve this naturally through Grav.

So far, I:

  • Created the proper setup.php file in the root (setup_subdirectory.php noted on Multisite Setup | Grav Documentation)
  • Created the env/mysubdomain/ folder with pages, plugins, themes, and config.
    – The config folder has system.yaml with the theme set to the main theme (it tries loading quark otherwise)
    – The pages folder has a home page
    – The plugins folder is empty (no unique plugins needed on this subdirectory)
    – The themes folder is empty

Initially, when trying to view the page,

Theme ‘main-theme’ does not exist, unable to display page.

shows. I can’t copy the theme out of the user/themes directory since the main site uses it there.

How would I set it up where a subdirectory website would use that main theme? I tried even making a child theme that inherits off of that main theme but since the main theme is in the user folder and not in env, I get the ‘theme not found’ error still.

@hdwebpros, I’m not familiar with multi-site, but got curious…

I’ve setup site http://multi-dev. To create a multi-site environment with subfolder site http://multi-dev/xx I did the following:

  • Created file setup.php with content from setup_subdirectory.php as shown in the docs.
  • Created folder user/env/xx
  • Created folders user/env/xx/config, user/env/xx/pages, user/env/xx/themes and user/xx/plugins
  • Created a few pages below user/env/xx/pages
  • Pointed browser to http://multi-dev/xx and got error: “Theme ‘quark’ does not exist, unable to display page.”
    Which is not unexpected, because Quark does not exist below user/dev/xx/themes

Grav uses so called Streams to find files. Grav searches through a list of folders with a prefix listed for the stream until it finds the file.

To make Grav look for Quark in /user/env/xx/themes and /user/themes I changed the stream for user as listed in setup.php to:

'user' => [
  'type' => 'ReadOnlyStream',
  'prefixes' => [
     '' => ["user/{$folder}", "user"],

When pointing the browser to http://multi-dev/xx the home page is now displayed correctly.
Any changes to templates in user/themes/quark/templates are also shown in site http://multi-dev/xx.

I’m not sure if this is the right way and file setup.php does contain a warning: “DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING!”.

Since multi-site is an unknown territory to me, I’m not sure if I know what I’m doing…

You’ll need to test thoroughly!

That was it! Perfecto! Thank you