I have taken over a project and Im having a small problem with locales.

It is running Craft 2.6.3016

A section has a locale “en” where the english URL format is “en/contact”, and the entry also have the slug “en/contact”… So, I would expect this URL to be domain.com/en/contact/en/contact, no? But it is not!

enter image description here

enter image description here

When getting the URL with this code:

{{ craft.entries.section( 'contact' ).first().url }}

the url is “domain.com/en/en/contact”, this link does not work, but if I change it to “domain.com/en/contact” as I would expect it to be, it works!!

I have no idea what kind of dark magic that messes around with this, but maybe some of you got any ideas? Nothing seems to make any sense here. Also note that the “en” folder in the public folder is called “en__” if I change this to “en” the locale stops working.

Any help appreciated!

If your entry's slug is en/contact and you need it to show up when you go to the URL domain.com/en/contact/en/contact, the Section settings for the Entry URL Format should be en/contact/{slug}:

enter image description here

Also, you shouldn't need to use the language code prefix (en/) in Section settings. That should be defined in your config/general.php file. See the Define your site URLs section of the Craft 2 docs on localization.

return array(
    // ...
    'siteUrl' => array(
        'en' => 'http://example.com/en/',
        'no' => 'http://example.com/no/',
    ),
);

Then, if you Section's URL settings are contact/{slug}, these URLs will both work:

http://example.com/en/contact/en/contact
http://example.com/no/contact/en/contact

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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