Ghost as CMS
For all of my tiny life, I was always doing my website by hand, writing directly into my code editor. It was great, simple and easy to deploy - but something was never feeling quite right...
For example, each time I needed to add a media file, I had to put it in the right folder, then write back the correct link (which is now much easier with good autocompletion in great IDEs). Then, I would check that everything displayed correctly before pushing new modifications. It wasn't a lot, but even this tiny bit of friction was too much to make me add content more regularly to my website.
Since WordPress, I had been biased towards thinking that CMS (Content Management System) software was bad. Not enough customization options and too much complexity for a simple personal website. I had heard about Ghost a long time ago, but I always thought it was only suited for hosting multiple people's Medium-style websites, so it seemed far too complicated for a personal website.
Lately, however, I've discovered that Ghost can be used as an easy CMS directly on my local machine - without having to host it somewhere! You just export your website as static and serve it easily from your favorite platform, such as GitLab Pages, for me.
Now some tiny details about the config...
I use Git LFS for large files like videos, so everything can still be hosted by Gitlab.
git lfs install
git lfs track "*.mp4"And after installing wget and gssg, I can simply generate this site handled by a local ghost install using the next command.
gssg --productionDomain http://www.ldavid.fr --dest ldavid/distI've needed also a way to replace all occurences of localhost everywhere by the right production domain, not well handled by gssg.
For now I use commands in the .gitlab-ci.yml like:
find . -type f \( -name "*.html" -o -name "*.json" -o -name "*.xml" -o -name "*.xsl" \) -exec sed -i '' 's|https://ldavid-f1d645.gitlab.io|https://www.ldavid.fr|g' {} +
find . -type f \( -name "*.html" -o -name "*.json" -o -name "*.xml" -o -name "*.xsl" \) -exec sed -i '' 's|//ldavid-f1d645.gitlab.io|//www.ldavid.fr|g' {} +Then, I can just commit and push into a Gitlab repository that deploy by default everything with the following .gitlab-ci.yml
# tiny image for fast deployment
image: alpine:latest
create-pages:
script:
- mv dist public
- find . -type f \( -name "*.html" -o -name "*.json" -o -name "*.xml" -o -name "*.xsl" \) -exec sed -i -e 's|https://ldavid-f1d645.gitlab.io|https://ldavid-f1d645.gitlab.io|g' {} +
- find . -type f \( -name "*.html" -o -name "*.json" -o -name "*.xml" -o -name "*.xsl" \) -exec sed -i -e 's|//ldavid-f1d645.gitlab.io|//ldavid-f1d645.gitlab.io|g' {} +
pages:
publish: public
rules:
# publish only for commit on main
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCHAnd tada 🎉
I've also configured Ghost to remove all the membership, newsletters and analytics, as it is not useful for a personal website. If someone wants to follow my activity, it can directly follow the RSS feed.
