I'm working on my first subfolder-based Craft site, so I'm relying on Asset URLs based on the {{ siteUrl }} variable. I cannot, however, manage to get them working. Any tags I add to the URL field in the control panel get printed literally (not parsed) in the template output.

My config.php looks like this:

return array(

    '*' => array(

    'foo.craft.dev' => array(
        'siteUrl' => 'http://foo.craft.dev/',
        'devMode' => true

    'foo.bar.com' => array(
        'siteUrl' => 'http://foo.bar.com/',
        'devMode' => true

    'example.com' => array(
        'siteUrl' => 'http://example.com/foo',
        'devMode' => false


My Logos Asset settings look like this:

enter image description here

And a relevant chunk of template looks like this:

<div class="logos">
    {% for logo in logos.logoImages %}
        <a href="{{ logo.websiteUrl }}" target="_blank" style="background-image: url({{ logo.geturl() }}); padding-top: {{ logo.getHeight() }}px; width: {{ logo.getWidth() }}px;">{{ logo.companyName }}</a>
    {% endfor %}

The background-image URL above renders out as {siteUrl}assets/logos/logo.gif, which isn't parsed as I would expect.

What have I done wrong?


If you want to use the {siteUrl} tag in your Asset source settings, you'll still additionally need to define it in your environment variables as well.

See here as well.

  • Ohhhhhh. And here I thought I was already doing that. Turns out I need an actual 'environmentVariables' => array( 'siteUrl' => 'http://whatever.com/' ). Matt 0, RTFM +1. Thanks Brad.
    – Matt Stein
    Jul 25 '14 at 21:59

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.