A while back I added og:image generation for posts and pages and later extended it to support devlogs. I did not however add it to notes for two reasons:

  • My github action that deploys the blog generates all the images on every push - adding notes would more than double deploy time
  • I didn’t want to solve the above issue by commiting the images to source

Today I solved this via two key changes:

  1. The generator will now skip existing images by default and;
  2. The generated images are cached via actions/cache.

The relative section from the github workflow looks like this:

- uses: actions/cache@v4
  name: Restore cached images
  with:
    path: _site/assets/cards
    key: cards-${{ github.sha }}
    restore-keys: |
      cards-

- run: ./scripts/generate-images.sh ${GITHUB_WORKSPACE}
  name: Generate images

The restore key matching on cards- means the last run always matches, returning all previously generated images. The result is now each notes page has a unique og:image:

notes on ravendb image