2

just built a blog with craft, and I got some issues with assets pathing. In the general.php I put

return array(
    'environmentVariables' => array(
            'basePath' => '/images',
            'baseUrl'  => 'https://site.com',
        )
);

But when I put {basePath} to assets path, the system creates a {basePath} named folder in root and looks for the image folder there. Also the {baseUrl} is looking like this in the code:

https://site.com/{baseUrl}/images/image.jpg

Am I doing something wrong?

3

Assuming this is using Craft 3, you should use aliases.

In your config/general.php add:

'aliases' => [
    'web' => 'https://site.com',
    'webroot' => dirname(__DIR__) . '/web'
],

Then in your Control Panel, under Settings → Assets → Images, set your Base URL to @web/images and File System Path to @webroot/images.

  • Thank you so much Oli, this resolved the issue. – simthesecond Apr 17 '20 at 13:05

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.