[英]Hugo Data Templates That Contain Title of Page
When using Hugo , is it possible to display a data template using the .Title
function? 使用Hugo时 ,是否可以使用
.Title
函数显示数据模板? For example, here is my data template function <p>{{.Site.Data.config.TextOne}}</p>
. 例如,这是我的数据模板函数
<p>{{.Site.Data.config.TextOne}}</p>
。 It grabs the string TextOne
from my data template file in the directory /data . 它从目录/ data中的数据模板文件中获取字符串
TextOne
。 However, I want to be able to use the title of the page or a variable in the place of .TextOne
. 但是,我希望能够使用页面标题或
.TextOne
位置的.TextOne
。 Kind of this {{.Site.Data.config.Title}}
. {{.Site.Data.config.Title}}
种类。 That of course doesn't work. 那当然是行不通的。
What might be alternatives or solutions to this request? 此请求的替代方案或解决方案可能是什么?
Figured it out. 弄清楚了。 Allowing the function to operate separately with the
.Title
function and calling the index
I was able to call strings of data based on the title of the page. 允许该函数与
.Title
函数分别操作并调用index
,从而能够根据页面标题调用数据字符串。
<p>{{index .Site.Data.config .Title}}</p>
Documentation this can be found of Hugo's docs website . 可以在Hugo的docs网站上找到相关文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.