百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

tcardgen

> 编程语言
开源

为您的 Hugo 文章生成 TwitterCard (OGP) 图像。

191 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

为您的 Hugo 文章生成 TwitterCard (OGP) 图像。

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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogohacktoberfesthugoimage-processing

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

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