Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

tcardgen

> 编程语言
Open source

Generate a TwitterCard(OGP) image for your Hugo posts.

191 stars0 likes1 views
WebsiteGitHub

About

Generate a TwitterCard(OGP) image for your Hugo posts.

Twitter Card Image Generator

Generate Twitter card (OGP) images for your blog posts. Supported front-matters are title, author, categories, tags, and date. Also, both toml and yaml formats are supported.

Installation

Homebrew

bash
brew install Ladicle/tap/tcardgen

Go version NOTE: tcardgen parses a font style from the file name,

so the font file must follow the naming rule (-.ttf), and arrange font files as follows:

bash
$ tree font/
font/
├── KintoSans-Bold.ttf
├── KintoSans-Medium.ttf
└── KintoSans-Regular.ttf

0 directories, 3 files

$ tcardgen -f path/to/fontDir \
           -o path/to/hugo/static/imgDir \
           -t path/to/templateFile \
           path/to/hugo/content/posts/*.md

After successfully executing the command, a PNG image with the same name as the specified content name is generated in the output directory.

Advanced Generation

If you want to change the color, style, or position of text, you can pass a configuration file with the --config(-c) option. Refer to the example/template3.config.yaml to see how to configure it.

bash
$ tcardgen -c example/template3.config.yaml example/blog-post2.md
Load fonts from "font" directory
Load template from "example/template3.png"
Success to generate twitter card into out/blog-post2.png

Result

OGP setting for Hugo Theme

On my blog, I place the generated images in the static/tcard directory. In order to load this image, I set the following OGP information for my blog theme. If the thumbnail is defined in the post, it is used first. Otherwise, the generated Twitter Card is used. If the page is not blog post, to set the default image.

xml

Generate images of updated articles

You can generate only the image of the updated article by using git diff and tcardgen.

bash
$ git diff --name-only HEAD content/post |\
    xargs tcardgen -o static/tcard -f assets/fonts/kinto-sans -t assets/template.png

Usage

…

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gogohacktoberfesthugoimage-processing

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言