I’m migrating multiple sites from another CMS over to Ghost. When I copy over images in bulk over to the /content/images/ directory (or theme /assets/images/) and then point to them relatively (i.e. /content/images/piece-of-pie_products.jpg) via the HTML UI editor during creation of a post/page, after publishing, the src urls change to absolute (i.e. http://localhost:2368/content/images/piece-of-pie_products.jpg)
This may work fine locally, but absolute URLs are the devil and wreak havoc when I export/import into pre-prod and production environments. Is there a way, globally, I can set URLs to maintain relativity as opposed to changing to absolute? I have multiple Ghosts instances running and I don’t think it was as much as a problem with some older versions. Maybe something has changed in newer versions? Thank you for your help in advance!
Image urls are stored in the database as relative, it’s only in the front-end html and API output (and therefore editor which is an API client) that they are forced to absolute to ensure compatibility when using separate front-end/admin urls or when integrating with external systems. What havoc is this causing? There shouldn’t be any issues exporting/importing because the underlying data is relative.
Thanks Kevin. When working locally in my dev environment, if I publish a page using relative source URLs for image, when I return to edit mode, those URLs show as absolute. I can’t get them to stay relative after publish. Then, if I am to export all content out of my local dev environment and import them into another instance (say a pre-prod instance of Ghost running in Docker with a different IP/non-localhost), those absolute image URLs will no longer work and I have to re-publish the page.
This is expected, as I said above we output absolute URLs everywhere for compatibility reasons, however the URLs are stored in the database as relative so that url config changes, export, and import across sites and domains still works. Have you tried an export and import?