2

Method "siteUrl" for object "Craft\ConfigVariable" does not exist

{% for locale in otherLocales %}

    {# Is this an entry page? #}
       {% if entry is defined %}

         {# Find the current entry in the other locale #}
        {% set localeEntry = craft.entries.id(entry.id).locale(locale).first %}

        {# Make sure that it's actually localized to this locale #}
       {% if localeEntry.locale == locale %}

           {# Output a link to it #}
            <link rel="alternate" hreflang="{{ locale }}" href="{{ craft.config.siteUrl[locale] ~ (localeEntry.uri != '__home__' ? localeEntry.uri) }}">
         {% endif %}

    {% else %}

        {# Just output the same path with the locale's base URL #}
        <link rel="alternate" hreflang="{{ locale }}" href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}">
    {% endif %}
{% endfor %}
1
  • 2
    Please add more information to your question... specifically, code from config file showing how "siteUrl" is set...
    – Anna_MediaGirl
    Jul 11 '14 at 18:10
4

Did you configure siteUrl in general.php?

return array(
    // ...
    'siteUrl' => array(
        'en' => 'http://example.com/en/',
        'de' => 'http://example.com/de/',
    ),
);
2
  • Yes. Also in the index.php. I use a multi-environment config file and the site is multi-language. Jul 11 '14 at 17:16
  • @JohannesLamers Can you share what the relevant part of your multi-environment config looks like?
    – Brad Bell
    Jul 14 '14 at 23:56

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.