Skip to content

Automate social image generation#508

Open
kacperlukawski wants to merge 32 commits into
mainfrom
social-image-generation
Open

Automate social image generation#508
kacperlukawski wants to merge 32 commits into
mainfrom
social-image-generation

Conversation

@kacperlukawski

Copy link
Copy Markdown
Member

The social preview images are used by LinkedIn and X natively whenever someone shares a link to the website. This PR attempts to automate this process by using templates specific to the content type. It is possible to define how YAML frontmatter attributes are rendered over the image in a configuration file. Currently, the images are generated when the build.sh script is launched, but eventually should be run either as a GH bot or a pre-commit hook.

Requirements:

  • ImageMagick

@kacperlukawski kacperlukawski added the documentation Improvements or additions to documentation label Mar 5, 2026
@vercel

vercel Bot commented Mar 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
haystack-home Ready Ready Preview, Comment Jun 23, 2026 10:06am

Request Review

@kacperlukawski

Copy link
Copy Markdown
Member Author

@bilgeyucel This PR is a draft, as I see it now more like a github action that runs this process and commits automatically. If we decide to add this, here is how the social preview image would look like:

image

@kacperlukawski kacperlukawski marked this pull request as ready for review March 25, 2026 10:57
@kacperlukawski kacperlukawski requested a review from a team as a code owner March 25, 2026 10:57

@bilgeyucel bilgeyucel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this, thank you @kacperlukawski!

Comment thread scripts/social-images/README.md Outdated
Comment thread static/images/social/authors/andrey-a.png Outdated
Comment thread static/images/social/blog/agentic-rag-in-deepset-studio.png Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that emojis in the content title are not rendered in the thumbnail. I believe this problem causes the space in front of "Cookbook"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love having them for integrations! Are they rendered once? What happens when we decide to change the description? Also, do we need to make further changes on the haystack-integrations repo, especially in the frontmatter of the pages?

Comment thread scripts/social-images/fonts/CourierPrimeBold.ttf Outdated
Comment thread scripts/social-images/config.yaml Outdated
@kacperlukawski kacperlukawski force-pushed the social-image-generation branch from 991c7e1 to 8bc3540 Compare April 29, 2026 15:18
@socket-security

socket-security Bot commented Apr 29, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​python-frontmatter@​1.3.099100100100100
Addedpypi/​pyyaml@​6.0.3100100100100100

View full report

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Status Count
🔍 Total 1524
🔗 Unique 562
✅ Successful 1423
⏳ Timeouts 0
🔀 Redirected 45
👻 Excluded 94
❓ Unknown 0
🚫 Errors 7
⛔ Unsupported 0

Errors per input

Errors in ./public/benchmarks/index.html

Errors in ./public/nlp-resources/index.html

Full Github Actions output

kacperlukawski and others added 26 commits June 23, 2026 12:04
- Remove blog template (images not needed; posts have their own thumbnails)
- Add exclude list (blog, authors) so generation skips those content types
- Switch all title fields from Inter-Bold to HafferBold per reviewer request
- Fix Integration.png template path case (was integration.png — broke on Linux CI)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add _strip_emoji() helper that removes emoji, ZWJ, variation selectors,
  skin-tone modifiers, and regional indicators, then collapses whitespace
- Apply stripping to title and description in ContentFile.load() — fixes
  the leading space before "Cookbook" caused by ImageMagick not rendering
  the 🧑‍🍳 emoji
- Load exclude list from config.yaml (top-level `exclude:` key) in Config
- Add Config.is_excluded() method
- Skip excluded content types early in FileProcessor.process()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drop Courier Prime, all Greycliff CF variants, and Inter-Bold.
Remaining fonts: HafferBold (titles), HafferMedium, HafferRegular,
Inter-Regular (body text).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Blog posts have dedicated thumbnails in their frontmatter; author pages
will fall back to the site-wide default OG image. Neither needs generated
social images, and the generator is now configured to skip both types.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Update YAML example: GreycliffCFExtraBold → HafferBold, drop stale output_dir key
- Update fonts list: remove Courier + Greycliff, list only Haffer + Inter
- Fix templates table: Integration.png (correct case), cookbook.png, remove stale overview row
- Document the new top-level exclude: config key

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace `convert` with `magick` to match generate.py and ImageMagick 7+
- Replace nonexistent template_cfg.output_dir with the standard path
  static/images/social/<type>/ used by FileProcessor

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds .github/workflows/social-images.yml, triggered on pull_request
for any content/**/*.md change. The job installs ImageMagick 6
(with a `magick` alias for IM7 compatibility) and the Python deps,
diffs the PR head against base to find added/modified/deleted files,
runs generate.py --file --force for each changed file, git-rms orphaned
PNGs for deleted markdown, then commits and pushes via GITHUB_TOKEN.
Fork PRs emit a ::notice:: instead of pushing.

build.sh is left untouched — it remains idempotent (skips existing
images) and still generates images for external content types
(tutorials, cookbook, integrations, advent-of-haystack) whose .md
files are pulled at deploy time and are not present in this repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Images are now committed to the repo via the GitHub Action on each PR
that changes content/*.md files. Regenerating at deploy time requires
ImageMagick which isn't available in the build environment and adds
unnecessary overhead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kacperlukawski

Copy link
Copy Markdown
Member Author

@bilgeyucel I would appreciate if you could have another look. I implemented the requested changes + created a github action that triggers the generation once there are any changes in the .md files and commits the images separately. There is a test PR created how that works here: #549

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants