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!

3 Answers 3

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.

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.