Skip to main content
15 votes
Accepted

Craft 3 language switcher

The concept of localization has changed in Craft 3, there are not only locales anymore - now you have different sites and site groups. Example without multisite - only different locals You can get ...
Robin Schambach's user avatar
9 votes
Accepted

How do I get the primary site URL?

You can output the primary site’s Base URL like this: {{ craft.app.sites.primarySite.baseUrl }} (craft.app.sites maps to craft\services\Sites.) If your Base URL begins with an alias, you will need ...
Brandon Kelly's user avatar
8 votes
Accepted

Craft 3: how can I set dynamic Base URL in sites setting?

So as of Craft CMS 3 RC7, they added a new alias() Twig function. So what you can do is something like this in your general.php: 'aliases' => [ '@basePath' => getenv('CRAFTENV_BASE_PATH'), ...
andrew.welch's user avatar
  • 11.6k
6 votes

Multi-site setup in Craft3

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 ...
CraftQuest's user avatar
  • 1,067
6 votes
Accepted

Craft 3 Multi-site with no "default" site

This can be done in 3 main steps. 1. Get the site subdirectories working First just get the /en/ and /es/ subdirectory working: Create en/ and es/ subfolders in your webroot Each subfolder should ...
Brandon Kelly's user avatar
5 votes

Craft 3 language switcher

Little addition with a fallback to the homepage and check if entry exist. currentSite is a global variable already defined in craft3 https://docs.craftcms.com/v3/templating/global-variables.html#...
Jeroen's user avatar
  • 308
5 votes
Accepted

Craft 3 multisite - are entries accessible between sites?

Yes it is. Just include the site id of the the site in your query set siteId = 2 set entries = craft.entries.section('foo').site(siteId).all() if you want to get the current entry for another site ...
Robin Schambach's user avatar
5 votes
Accepted

Can you get the baseUrl for site by handle or id?

{% set site = craft.app.getSites().getSiteById(1) %} {% set site = craft.app.getSites().getSiteByHandle('handle') %} {{ site.baseUrl }} But I would rather suggest you to grab the entries URL for a ...
Robin Schambach's user avatar
5 votes
Accepted

How to order Sites

I've seen that before, if you look at the sites table in your DB, you'll see that a few sites might have their sortOrder set to 1. If you go to Settings → Sites → [the offending group] in your ...
Oli's user avatar
  • 7,495
4 votes
Accepted

Multi-site setup in Craft3

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's user avatar
4 votes

Loop through all sites in multisite installation

Nikolay, As I responded in the slack, I will respond here in case anyone else has this question. In the template you can access this information like so: SiteUrl: {{ siteUrl }} Langauge: {{ craft....
Rick Kukiela's user avatar
4 votes
Accepted

Loop through all sites in multisite installation

If you want to do this purely from a template, then something like this: {% set sites = craft.app.sites.getAllSites() %} {% for site in sites %} <li>{{ site.name }}</li> {% endfor %} ...
Brad Bell's user avatar
  • 67.5k
4 votes
Accepted

Craft 3: with Base URL of site set up using @web alias, how to display the original URL in Twig templates?

So luckily for us, Brandon recently added the alias() Twig function. It should show up in Craft CMS 3 RC7. You can see the discussion about it here: https://github.com/craftcms/cms/issues/2327
andrew.welch's user avatar
  • 11.6k
4 votes

Craft 3 language switcher

As of today, Site Switcher is now available in the plugin store! * It was called "Language Link" in Craft 2, but the premise is the same... It allows you to switch between sites while staying on the ...
Lindsey D's user avatar
  • 24k
4 votes

Craft 3 multi-lingual multi-sites setup with shared assets

You could create 2 site groups. One group for site A and one group for site B. Sitegroup A will contain contain 2 sites, the other one only one site. Your setup will look like this SiteGroup A -...
Robin Schambach's user avatar
4 votes
Accepted

Craft 3 Multi Language Setup

First of all you should remove all "language" subfolders from your web directory because your web server will route directly in those instead of your default web/index.php. Craft will determinate the ...
Robin Schambach's user avatar
4 votes

Craft 3 Multi Language Setup

Use aliases, by first defining them in your general.php: 'dev' => [ 'siteUrl' => [ 'default' => 'https://site.test', 'korean' => 'https://site.test/ko', ...
Jolle's user avatar
  • 95
4 votes

How do I get the primary site URL?

{{ siteUrl }} should do the trick for you.
andrew.welch's user avatar
  • 11.6k
4 votes
Accepted

Can two sites use the same channel, but have unique entries?

There is a light switch field in your section settings with the label "propagate entries across all sites". Just turn it off and your entries will be unique
Robin Schambach's user avatar
4 votes
Accepted

How to save entry to the current site from the front end?

The parameter is called siteId <input type="hidden" name="siteId" value="{{ currentSite.id }}">
Robin Schambach's user avatar
4 votes
Accepted

How to route 404 errors for multi-site Craft?

I pondered this for a while, and then did this, which will direct us to specific entries (not templates, I don't want to create more of those): {# We need a unique 404 for each site - just take us to ...
4midori's user avatar
  • 656
4 votes
Accepted

Displaying one site's content in another site (Craft 3 Multi-site)

I figured it out! In Section settings > Propagation Method, you must choose 'Save entries to all sites enabled for this section', or, if you're using site groups, choose the appropriate group. This ...
4midori's user avatar
  • 656
4 votes
Accepted

Is it possible to localize Freeform fields and labels?

You can render the fields by your own and use the twig translate filter and do it with translation files. But I think there is no way to do it via the CP currently.
davidhellmann's user avatar
4 votes
Accepted

How do you insert the site name into a default asset path?

Try using {site.handle} instead of {{currentSite.handle}} and it should work ok.
revlis's user avatar
  • 328
4 votes
Accepted

On a Craft 3 multi-site, how can I setup an Entries field to select entries from other sites?

In entries field has an option Show the site menu, so this will give you a dropdown to select site when selecting entries. But the problem it doesn't save the site relation. If your channels is only ...
aodihis's user avatar
  • 801
3 votes
Accepted

Craft 3: how can I set an ordered list of all sites, and set a display name different from the site name?

If you would use a custom plugin you can create this function in your (I know it's deprecated but I don't know a better name) PluginVariable public function createSiteQuery(): Query { return (new ...
Robin Schambach's user avatar
3 votes

Craft 3 language switcher

If you're using SEOmatic for Craft CMS 3, there's a built-in function that will make it super easy to do: seomatic.helper.getLocalizedUrls(URI, SITE_ID) - Return a list of localized URLs for a given ...
andrew.welch's user avatar
  • 11.6k
3 votes
Accepted

Two domains - single install - Live Preview works only on one

In order to get Live Preview to work across different subdomains on a single install, you'll need to setup a few extra things as outlined in this support article: https://craftcms.com/support/cross-...
Brad Bell's user avatar
  • 67.5k
3 votes

Craft 3 multisite - are entries accessible between sites?

I needed to aggregate blog posts entries from ~20 schools (multi-sites) and display them on the main site. Like others, I realised way to0 late in the development that this wasn't an out of the box ...
Jamie Taylor's user avatar
3 votes

Locale URL segment being duplicated, eg https://website.test/en/en/

Your issue is that the @web alias resolves to this: The URL to the folder that contains the index.php file that was loaded for the request Now that you’re serving your English site from web/en/...
carlcs's user avatar
  • 36.2k

Only top scored, non community-wiki answers of a minimum length are eligible