在一个短代码中,我想要创建一个到hugo页面的链接,我如何做到这一点?
我试过了
{{< ref "page_name" >}}但是我得到了一个错误parse failed unexpected "<" in command。
例如,我可以使用<a href="https:/www.example.com/test/">Test</a>,但这与站点所在的域绑定在一起,我希望能够不受此限制地使用它。
谢谢你的帮助
发布于 2022-06-30 20:01:35
我找到了如何做到这一点,这个链接很有帮助:
https://github.com/parsiya/Hugo-Shortcodes/blob/master/shortcodes/xref.html
因此,在我使用的短代码中:
{{ $path := .Get "path" }}
{{ $path := trim $path "/" }}
<!-- now pass it to the relref function -->
{{ $relreflink := relref . $path }}
<a href="{{ $relreflink }}" title="Some title" rel="nofollow" target="_blank">Some text</a>在标记代码中,我可以使用:
{{< my-shortcode path="/my_page" >}}
好像很管用。
发布于 2022-06-30 19:39:35
也许你需要的是relref
来自文献资料
{{< relref "document" >}}
{{< relref "document.md" >}}
{{< relref "#anchor" >}}
{{< relref "/blog/my-post.md" >}}发布于 2022-06-30 19:55:31
[]() <- Hugo是降价的--这是创建带有减价链接的方法。
所以:
[Test](/test/)如果您想要具体使用一个短代码,那么各种短代码的另一个答案是有效的--但是上面给出了您想要的描述。
https://stackoverflow.com/questions/72820972
复制相似问题