Best approach setup of 3 similar sites?

I’m setting up a website for a organisation that organize events in 3 different city. So every city should have it’s own website. 3 times a identical website from a template, css etc. perspective. Only the content will be different.

So I’m thinking to setup 1 site and then copy it for the other cities. Not ideal from a maintenance perspective. Is it possible to manage everything with the same templates and panel? So there is just 1 point of maintenance.

Or if you have any other solution, let me know.

Many thanks!

Check out the documentation on setting up a multi-site:

https://getkirby.com/docs/developer-guide/configuration/folders#multi-site-setup

1 Like

Wow :smiley: that’s awesome! To easy!
Thank you very much!

@texnixe It looks really easy, but somehow I don’t get it to work.

To clarify, the situation is that I have 3 websites that only differ in content. Each site has his own folder: www.mydomain.com/folder1, www.mydomain.com/folder2, www.mydomain.com/folder3

In those site folders I only put the content folder of that website. And the site.php is like this:

// /site.php

$kirby = kirby();
$domain = server::get(‘server_name’);
$domains = array(‘www.mydomain.com/folder1’, ‘www.mydomain.com/folder2’, ‘www.mydomain.com/folder3’);

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

// custom roots
$kirby->roots->site = DIR . DS . ‘site’ . DS . $domain;
$kirby->roots->content = DIR . DS . ‘content’ . DS . $domain;

// custom urls
$kirby->urls->index = url::scheme() . ‘://’ . $domain;
$kirby->urls->content = $kirby->urls->index . ‘/content/’ . $domain;

It doesn’t work. What am I doing wrong? Do I need to put anything in the “server_name”?

multisite setup only works if all domains point towards the same destination.

since kirby is really not depending on anything outside it’s base folder, you might just go for a general purpose template / setup, where you can swap out the contents after you duplicated the whole website folder…

a great idea is to use composer, so if there’s an update for anything like kirby, or other plugins you can just update with one command and publish the changes.

1 Like

Please check $domain. Is it like one of the full entries in $domains?

Do you have the three subdirs under site and content as subdirs of a directory with the name of your domain?

What do you mean by “multisite setup only works if all domains point towards the same destination”?

If all the domains have the same destination then it’s just one site.

… Is what you need. The three websites have ONE Kirby Installation!
It is the root of your Kirby Installation.

The final bracket is missing in “sites.php”.

What should I define at “$domain”? In other words, what should be the “server_name”?

What I’m trying to is have 1 “site” folder and 1 “kirby” folder. And 3 different content folders. How should I set up the site.php? https://getkirby.com/docs/developer-guide/configuration/folders#multi-site-setup

This is way out of my knowledge, any help is appreciated. Thanks!

In your script “site.php”:
What is the dump of “$domain” for each website?

If you use apache:
Please show us your vhost configuration of these websites

Or tell us your webserver.

the multi setup as mentioned before handles access differently

all sites are found in the same installation folder so all DOMAINS will have to point to the same directory.

the magic then happens with the kirby configuration.
kirby will check which domain is being accessed to and call the appropriate content for that

the $domains array inside the site.php is the key factor there.
you specify which domains are pointed towards kirby there… (where your index.php and all files/content is being uploaded to)

$domains = array('site1.com', 'site2.com'); 
// Just put all your domains you want to use there.

check out the multi-site setup which is linked above…

make sure for each domain you have all folders setup correctly such as

/site/site1.com/
/content/site1.com/
/avatars/site1.com/
/thumbs/site1.com/

/site/site2.com/
/content/site2.com/
/avatars/site2.com/
/thumbs/site2.com/

EDIT:
for generally having only one template/blueprint/etcpp/
you can make kirby functions available from the outside, and change things like site folder, but i haven’t tried any of that…

<?php
define('DS', DIRECTORY_SEPARATOR);

// load kirby
require(DIR . DS . 'kirby' . DS . 'bootstrap.php');

$kirby = kirby();
$kirby->roots->site = '/var/sites/mysite.com';
?>

the time you invest in researching or playing around, i would’ve just used the multi-site setup or just have 3 seperate installations…

Thanks @carstengrimm that’s very helpfull. The multisite documentation didn’t mention anything about the folder structure. This is definitely the way to go.

It is working partly, yeah! :slight_smile:
Some roadblocks:

  • As homepage it renders the “site.txt.” information, do you know why this is rendered instead of the “home” folder?
  • The following line is giving the error: “Call to a member function children() on boolean”
<?php $articles = page('agenda')->children()->visible()->filterBy('date', '>=', strtotime("-1 day"));?>

Probably some relative path problem? Or is this something else?

This is all a bit outside my knowledge, but great to learn! Your help is much appreciated!