What is the difference between siteUrl and baseUrl in Craft 3? Is there any?


When you take a look into Craft you'll see this

 * @var string|string[] The base URL to the site(s). If set, it will take precedence over the Base URL settings in Settings → Sites → [Site Name].
 * This can be set to a string, which will override the primary site’s base URL only, or an array with site handles used as the keys.
 * The URL(s) must begin with either `http://`, `https://`, or `//` (protocol-relative).
public $siteUrl

So the baseUrl is what you insert in your site settings, the siteUrl can overwrite these values from your config

The Site.php (model) has a this function as well

 * Overrides the base URL while keeping track of the original one.
 * @param string $baseUrl
 * @return void
public function overrideBaseUrl(string $baseUrl)
    $this->originalBaseUrl = (string)$this->baseUrl;
    $this->baseUrl = rtrim($baseUrl, '/').'/';

which is called in the Site service


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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