1
Map the CDN resource to the asset location
Identify the public path where Craft stores the assets —
/uploads/ in a typical local setup. In the Gcore Customer Portal, configure the CDN origin so the same path resolves to that asset directory.The CDN domain and the Craft filesystem must use matching paths. If the CDN domain is cdn.example.com and the asset path is /uploads/, an origin request for /uploads/image.jpg must return the corresponding file.2
Configure the Craft filesystem
Log in to the Craft control panel and navigate to Settings > Filesystems. Create a filesystem or open the filesystem used by the required assets, then configure it:
- Enable Files in this filesystem have public URLs.
- In Base URL, enter a value that resolves to a stable absolute CDN URL —
https://cdn.example.com/uploads/, an environment variable, or a dedicated alias such as@cdn. - For a local filesystem, set Base Path to the matching server directory —
@webroot/uploads. - Save the filesystem.
@web alias, because its value can differ between sites. Craft documents these options in the asset filesystem settings.3
Attach an asset volume
Navigate to Settings > Assets. Create a volume or open an existing volume, attach it to the configured filesystem, and save the volume.When several volumes use the same filesystem, assign each one a unique, non-overlapping base path.A volume can store image transforms in a separate filesystem. Transformed images in that filesystem do not automatically use the CDN URL of the original assets. Configure the transform filesystem with public URLs and a Base URL that also resolves to the CDN domain. If the transform filesystem is left unchanged, this procedure covers only files stored in the selected filesystem.
4
Upload or select an asset
Navigate to Assets, select the configured volume, and upload a file. Existing assets in a volume attached to this filesystem use the new Base URL automatically.Replacing an asset at the same path can leave the previous file in the CDN cache. Enable Craft’s
revAssetUrls setting so asset URLs change after a replacement, or purge the affected URL from Gcore.5
Use the Craft-generated asset URL
In Craft templates, render the asset URL with
asset.url or asset.getUrl(). Hardcoded origin URLs bypass the filesystem Base URL and must be replaced with Craft-generated URLs.6
Verify CDN delivery
Open a page that contains the asset and use the browser developer tools:
- Open the Network panel.
- Reload the page.
- Select the asset request.
- Confirm that the request URL uses the CDN domain and returns a successful response.