> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate a CDN resource with Kirby

> Integrate a Gcore CDN resource with Kirby by setting media and assets URLs to a custom domain.

[Kirby](https://getkirby.com) can serve `media` and `assets` from a CDN by setting custom URLs when Kirby is initialized. Create a [CDN resource](/cdn/getting-started/create-a-cdn-resource/create-a-cdn-resource) before starting the integration, and confirm the [custom domain](/cdn/cdn-resource-options/general/create-and-set-a-custom-domain-for-the-content-delivery-via-cdn) is configured.

> [!WARNING]
>
> Back up `index.php` and the site files before making changes. If the installation uses a custom database integration, back up the database as well — default Kirby installations do not use a database. These steps assume the root `index.php` initializes Kirby with `new Kirby([...])` and has not been replaced by custom bootstrap logic. A custom bootstrap might not integrate correctly.

Before editing Kirby, collect the **custom domain** value to put in the `media` and `assets` URLs — it typically looks like `cdn.site.com`:

**1. Open the CDN resource**

In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **CDN** > **CDN resources** and open the resource.

**2. Copy the custom domain**

Note the **custom domain** shown for the resource — this is the hostname used in the Kirby `media` and `assets` URLs.

**3. Confirm the DNS CNAME**

Confirm that the custom domain has a CNAME record pointing to the Gcore target hostname shown in the Customer Portal (`cl-****.gcdn.co`). Do not put the `gcdn.co` hostname in the Kirby URLs.

**4. Confirm SSL**

Confirm the custom domain has a valid SSL certificate so assets can load over HTTPS.

Then update the Kirby configuration:

**1. Open index.php**

Open `index.php` in the site root.

**2. Set the media and assets URLs**

Set the `media` and `assets` URLs to the custom domain:

```php theme={null}
<?php

include __DIR__ . '/kirby/bootstrap.php';

$kirby = new Kirby([
    'urls' => [
        'media'  => 'https://cdn.site.com/media',
        'assets' => 'https://cdn.site.com/assets',
    ]
]);

echo $kirby->render();
```

**3. Save the configuration**

Save `index.php`.

**4. Confirm the integration**

Open the browser developer tools (press F12), select the **Network** tab, and refresh the page — media and asset files should now load from the custom domain instead of the original domain.

A plugin-based approach that rewrites only selected paths is described in the Kirby cookbook [Kirby loves CDN](https://getkirby.com/docs/cookbook/performance/kirby-loves-cdn).
