mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-09-12 08:18:37 +00:00
874 B
874 B
title, description, categories, keywords, params
| title | description | categories | keywords | params | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Name | Returns the shortcode file name, excluding the file extension. |
|
The Name method is useful for error reporting. For example, if your shortcode requires a "greeting" argument:
{{< code file=layouts/shortcodes/myshortcode.html >}} {{ $greeting := "" }} {{ with .Get "greeting" }} {{ $greeting = . }} {{ else }} {{ errorf "The %q shortcode requires a 'greeting' argument. See %s" .Name .Position }} {{ end }} {{< /code >}}
In the absence of a "greeting" argument, Hugo will throw an error message and fail the build:
ERROR The "myshortcode" shortcode requires a 'greeting' argument. See "/home/user/project/content/about.md:11:1"