Added urls:assets config option to serve static theme assets from CDN#27009
Added urls:assets config option to serve static theme assets from CDN#27009muratcorlu wants to merge 1 commit intoTryGhost:mainfrom
Conversation
Ghost already supports CDN base URLs for uploaded content (urls:image,
urls:media, urls:files), but static theme assets (/assets/* and /public/*)
have always been served from the origin. This adds urls:assets to complete
the picture.
When urls:assets is configured, all URLs produced by the {{asset}} helper
and Ghost's own public asset tags (cards.min.js, member-attribution.min.js,
etc.) are rewritten to use the CDN as the base instead of the origin.
Benefits:
- Improved page load performance: assets can load in parallel from origin domain
- Cookie-free domain: serving assets from a separate domain means browsers
don't send session cookies with every asset request, reducing request
overhead
- Easier CDN cache management: With the changes on Ghost, no need to drop CDN
caches for assets.
Configuration:
"urls": {
"assets": "https://cdn.example.com/my-site"
}
Theme assets resolve to:
https://cdn.example.com/my-site/assets/css/screen.css
Public assets resolve to:
https://cdn.example.com/my-site/public/cards.min.js
Note: when urls:assets is set, the Ghost subdirectory (if any) is not
included in the asset URL. The CDN base URL is used as-is. This is aligned with current CDN url configurations for images, media and files.Installations
running Ghost under a subpath (e.g. example.com/blog/) should ensure their
CDN is configured to pull from the correct origin path.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
I am not sure if I need to do anything about Sonar check, since it's mentioning repeating lines on test file, which is completely normal, I think. |


Ghost already supports CDN base URLs for uploaded content (
urls:image,urls:media,urls:files), but static theme assets (/assets/*and/public/*) have always been served from the origin. This addsurls:assetsto complete the picture.When
urls:assetsis configured, all URLs produced by the{{asset}}helper and Ghost's own public asset tags (cards.min.js,member-attribution.min.js, etc.) are rewritten to use the CDN as the base instead of the origin.Benefits:
Configuration:
Theme assets resolve to:
Public assets resolve to:
Note: when
urls:assetsis set, the Ghost subdirectory (if any) is not included in the asset URL. The CDN base URL is used as-is. This is aligned with current CDN url configurations for images, media and files. Installations running Ghost under a subpath (e.g. example.com/blog/) should ensure their CDN is configured to pull from the correct origin path.Got some code for us? Awesome 🎊!
Please take a minute to explain the change you're making:
Please check your PR against these items:
We appreciate your contribution! 🙏