Iβm trying to setup a multisite where 2 websites are 100% identical except the content. So only the content is uniek and should be managed separate in their own panel.
To be honest, I have a hard time understanding the code in the cookbook about the multisite. Can anybody point me in the right direction how I should configure this?
If itβs only about the content folder, then all you have to do is set content to the folder where your content is store in index.php
index.php
<?php
require 'kirby/bootstrap.php';
// in this array, the key refers to the domain, the value refers to the folder name, this can be different from the domain name. Inside those folders you would put the content and the media folders.
$sites = [
'my-site.com' => 'my-site.com',
'my-shop.com' => 'my-shop.com',
];
$host = Url::host();
$root = $sites[$host];
$url = 'http://' . $host;
$kirby = new Kirby([
'roots' => [
'index' => __DIR__,
'content' => $root . '/content',
'media' => $root . '/media',
],
'urls' => [
'media' => $url . '/' . $root . '/media',
],
]);
echo $kirby->render();
As I commented above, the array keys in the $sites array are your domain names, the values are the folder names where your domain-specific stuff is stored.
The root folder is retrieved from the $sites array, depending on which domain is called. Not sure if this works with subfolders. Check what dumping Url::Host() returns for each domain
As I said, I donβt know if this works with subfolders instead of (sub)domains, have never tried that. This setup usually assumes that you use domain names that all point to the same root.
Why do you use subfolders if this concerns different website?
Maybe the approach which I proposed in this recipe is easier for you to accomplish. It requires that you set up 2 virtual hosts, each will serve one of your sites. In addition, you need to have access to your file system because you have to replace folders with symbolic links. If this does not fit your situation, you can skip the remaining part of this answer.
Once you have setup your file system and virtual hosts as it is proposed in the mentioned recipe, it is easy to extend it to the site and assets folders. You just need to replace them with the according symbolic links.
In the following example file structure I did this and moved the kirby, site and assets folder to a folder kirby-shared outside of the virtual hosts root folders, which are kirby-site1/htdocs and kirby-site2/htdocs. Then I replaced these folders with symbolic links to the shared folder:
There is nothing special with the starterkit files I use for this. Just set up the kirby-site1 and kirby-site2 folders with the same starterkit and then move the folders of one site outside the virtual hosts docroots and replace all moved folders with a symbolic link. For the second and maybe even more sites just delete the folders and replace them by symbolic links. Just follow the cookbook recipe, especially the change to index.php: https://getkirby.com/docs/cookbook/setup/multisite-variant#in-index-php
If you are still lost, please specify at which point something is not working for you.
Good question - never thought about this, since initially, my primary goal has been to share the kirby program folder and to ease updating/testing with different versions.
However, thinking more about it, it would be better to not share the whole site folder, but only certain subfolders. I think I would definitely leave the cache, config and session subfolders as real folders and only symlinking the others like blueprints, controllers etc. Depends largely on what you want to achieve. If you would like to share accounts between your sites, share the accounts folder, if not, leave them alone.
If I want to share accounts between two kirby sites in a multisite installation, do I only have to point the accounts root to the same folder or also the sessions root? @texnixe