Ghost blog images not working after move to subdirectory?
As search engines mostly regard subdomains as a separate domain in ranking algorithms, we moved our Ghost blog from a subdomain to a subdirectory to optimise our search engine performance.
Ghost v0.4 has support for subdirectories out of the box, but there is some configuration that needs to be done. There is a good post on how to do this here.
If you moved your blog with existing content and images, you'll realise that your image links are broken after moving the blog. This is because image links in posts are hardcoded.
Instead of manually reuploading all your images, here is a simple workaround for those of you out there using a sqlite3 database, which is what Ghost uses out of the box. It involves running a search and replace on the database, so USE AT YOUR OWN RISK.
Step 1: Make backup of database
# in Ghost directory in terminal
cp content/data/ghost.db content/data/ghost.backup.db
Step 2: Replace hardcoded image links with new ones
sqlite3 content/data/ghost.db
# assuming your subdirectory is /blog
UPDATE posts SET markdown = replace(markdown, ';
UPDATE posts SET html = replace(html, '<img src="/content/', '<img src="/blog/content/');
# quit sqlite3
.quit
Now restart your blog and you should be set!
Subscribe
Get the latest posts delivered right to your inbox
More great reads
- Meilleur Site De Casino En Ligne
- Meilleur Casino En Ligne
- Paris En Ligne Belgique
- Paris En Ligne Belgique
- Paris En Ligne Belgique
- Casino En Ligne
- Siti Scommesse Non Aams
- Avis Application Sweet Bonanza
- онлайн казино України
- зарубежные казино онлайн
- Site De Pari En Ligne
- Paris Sportif Crypto 2026
- Casino En Ligne France Légal
- Sites De Paris Sportifs
- Casino En Ligne Nouveau Bonus
- Bonus Casino Sans Depot
- Recensioni Slot Sweet Bonanza
- Visa Casino Bonus
- Casino Online Senza Documenti