7

Hi guys are the any more detailed tutorials on how to setup a multi site on Craft3 BETA? I created two sites now, a Danish and English through the admin (Settings → Sites). The domain is the same but the Danish version will have the path http://localhost:8888/dk whereas the English version will be everything that does not have the first path of /dk.

I have set in the general.php the following:

return [
    '*' => [
        'omitScriptNameInUrls' => true,
        'usePathInfo' => true,
        'generateTransformsBeforePageLoad' => true
    ],
   'SITEHANDLE_NAME_ENGLISH' => [
       'siteUrl' => 'http://localhost:8888/
   ],
   'SITEHANDLE_NAME_DANISH’ => [
       'siteUrl' => 'http://localhost:8888/dk'
   ],
    'defaultWeekStartDay' => 1,
    'enableCsrfProtection' => true,
    'omitScriptNameInUrls' => 'auto',
    'cpTrigger' => 'admin',
    'devMode' => false,
];

In the Danish folder /dk, I created a new index.php, and the site correctly direct to this file from the URL, BUT, it does not change the site to the the Danish site, even though I have defined my index.php with the new php constant:

<?php
// Project root path
$root = dirname('../');
define('CRAFT_SITE', "SITEHANDLE_NAME_DANISH");
// Composer autoloader
require_once '../craft_folder/vendor/autoload.php';

// dotenv?
if (file_exists("../craft_folder/.env")) {
    $dotenv = new Dotenv\Dotenv("../craft_folder/");
    $dotenv->load();   
}

// Craft
define('CRAFT_BASE_PATH', "../craft_folder/");

$app = require '../craft_folder/vendor/craftcms/cms/bootstrap/web.php';

$app->run();

How do I tell Craft to load the Danish site from the index.php? Right now it will only load the primary site not matter what I try.

Thanks!

Cavell Blood
  • 693
  • 6
  • 21
trustkool
  • 73
  • 1
  • 3

3 Answers3

6

You can also check out the free video on it here: Using Craft CMS 3 Multi-site

Multi-site has changed as of Craft 3 RC11. It now requires much less config outside of the control panel. See the official docs on Sites in Craft 3.

Jalen Davenport
  • 3,045
  • 1
  • 9
  • 24
CraftQuest
  • 1,057
  • 9
  • 11
4

Have you watched the Craft Hangout?

Managing Multiple Sites in Craft 3 – Sites and Localization

Might be of use if you haven't. You'll need about an hour free to view it.

Steve Holland
  • 2,485
  • 1
  • 16
  • 31
1

I just set up a Norwegian (default) / English multi-site myself, without touching a single config file or adding files/directories (apart from the actual translation-file containing strings in different languages) to the project.

  • In the backend, I added the sites Norwegian with path @web (and saying that it is the main site) and English with path @web/en
  • Then I configured my sections and fields to my liking, i.e. determining which ones should support localization

And that was it - I see Norwegian content when accessing http://site.test and English content when accessing http://site.test/en

Fuglsetrampen
  • 436
  • 2
  • 13