Loop through all sites in multisite installation Who knows how to loop through all sites in multisite installation? I want to create kind of drop down menu to switch between websites.
I've found this code inside the backend template but looks like it doesn't works in frontend

{% for site in allSites %}
            &lt;tr data-id="{{ site.id }}" data-name="{{ site.name|t('site') }}"&gt;
                &lt;th scope="row" data-title="{{ 'Name'|t('app') }}"&gt;&lt;a href="{{ url('settings/sites/' ~ site.id) }}"&gt;{{ site.name|t('site') }}&lt;/a&gt;&lt;/th&gt;
                &lt;td data-title="{{ 'Handle'|t('app') }}"&gt;&lt;code&gt;{{ site.handle }}&lt;/code&gt;&lt;/td&gt;
                &lt;td data-title="{{ 'Language'|t('app') }}"&gt;&lt;code&gt;{{ site.language }}&lt;/code&gt;&lt;/td&gt;
                &lt;td data-title="{{ 'Base URL'|t('app') }}"&gt;&lt;code&gt;{{ site.baseUrl }}&lt;/code&gt;&lt;/td&gt;
                {% if multiple %}
                    &lt;td class="thin"&gt;&lt;a class="move icon" title="{{ 'Reorder'|t('app') }}" role="button"&gt;&lt;/a&gt;&lt;/td&gt;
                    &lt;td class="thin"&gt;&lt;a class="delete icon" title="{{ 'Delete'|t('app') }}" role="button"&gt;&lt;/a&gt;&lt;/td&gt;
                {% endif %}
            &lt;/tr&gt;
        {% endfor %}


UPD:
Now I can fetch names of websites by their Ids:

      {% set allSitesIds = craft.app.sites.getAllSiteIds() %}
  {% for site in allSitesIds %}
  {% set siteName = craft.app.sites.getSiteById(site) %}
  {{siteName}}
  {% endfor %}
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.app.language }}
Handle: {{ craft.app.sites.currentSite.handle }}


I'm not entirely positive how to loop the sites in the template but you can get a sites object in PHP by running the following in a controller somewhere or in the init() method of any plugin that is installed:

$sites = Craft::$app-&gt;getSites();
var_dump($sites);
exit;


This will output the structure of the sites object. Baring this you can look through the craft source / docs to find the details on the site object that returns. There should be a method for getting sites by id or by handle; $sites-&gt;getSitesByID() or $sites-&gt;getSitesByHandle() but I have not double checked this so you'll have to try it or look it up. If there is not a method then it should be accessible via an array property like $sites-&gt;sitesByHandle or $sites-&gt;byHandle. Again you'll have to double check on this.

By the way, that functionality should translate to the template version of the sites object craft.app.sites so you should be able to do:

{% set sites = craft.app.sites.getSitesByHandle() %}


Or something like that anyway.

Once you figure it out feel free to update this to reflect the proper methods / properties :)