文章链接卡片和跳转中转功能使用说明示例

发布时间:2025-11-24 10:00   浏览量:21
Alex书
时间就是生命,Life is money,Money is life
本文整理了 Demius 主题中最常用的两个文章增强组件:内置的链接卡片短代码 linkcard,以及外链跳转中转功能 linkRedirect。照着示例复制即可快速开箱。
链接卡片短代码(linkcard)
主题内置的链接卡片短代码是 linkcard。开启方式如下:


在 hugo.toml 中打开样式与默认配置:
[params.linkCard]
enable = true
defaultType = "auto"
openInNewTab = true
showArticleInfo = true
showArticleDate = true
showArticleSummary = true
showUrl = true


在 Markdown 中直接引用短代码,内部链接会自动读取文章的标题、摘要与日期:
{{< linkcard url="/posts/helloworld/" >}}






Hello World



2025-10-06

这是第一段
背景 balabala…
步骤一 详细内容…
总结 收尾






常用可选参数:

type: auto / internal / external
newtab, showinfo, showdate, showsummary, showurl
title, summary, date, ref



组合示例(自定义外链卡片):
{{< linkcard
url="https://gohugo.io/documentation/"
title="Hugo 官方文档"
summary="配置、模板语法与部署指南"
type="external"
showurl="false"
>}}






Hugo 官方文档

配置、模板语法与部署指南





外链跳转中转功能
中转页面由 content/go.md(layout = "go")和 /themes/demius/layouts/go.html 驱动,前端脚本会自动把文章内容区域的外链改写为 /go/?goUrl=...。使用流程:
查看原文

该站点最新相关文章