What’s the recommended way to set the site URL? There are multiple ways to set the site URL. What is the recommended way?
As of Craft 2, you should be using the new siteUrl config setting.



There are two advantages to setting your site URL using this config setting.

First, The value can be set on a per-locale basis, in a way where Craft is actually aware of all locales’ URLs on every request (unlike the CRAFT_SITE_URL constant, where Craft only knows the current locale’s URL). That’s a good thing because it means you can easily link to entries’ URLs across different locales, for example.

return array(

    'siteUrl' =&gt; array(
        'en_us' =&gt; 'http://example.com/',
        'de'    =&gt; 'http://example.com/de/',
    ),

    // ...

);


Its value can also be set directly on a per-environment basis. (Yes you can achieve this using the environmentVariables config setting combined with a {siteUrl} tag inside the Site URL setting within the CP’s general settings, but that’s much less direct/obvious.)

return array(

    '.dev' =&gt; array(
        'siteUrl' =&gt; 'http://example.dev/',
        // ...
    ),

    '.com' =&gt; array(
        'siteUrl' =&gt; 'http://example.com/',
        // ...
    ),

    // ...
);


Those of course can be combined as well:

return array(

    '.dev' =&gt; array(
        'siteUrl' =&gt; array(
            'en_us' =&gt; 'http://example.dev/',
            'de'    =&gt; 'http://example.dev/de/',
        ),
        // ...
    ),

    '.com' =&gt; array(
        'siteUrl' =&gt; array(
            'en_us' =&gt; 'http://example.com/',
            'de'    =&gt; 'http://example.com/de/',
        ),
        // ...
    ),

    // ...

);