У нас вы можете посмотреть бесплатно How to Make Your User Variables from config.toml Show Up in Page Body with Hugo или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
Learn how to effectively display user-defined variables from your config.toml in your Hugo pages. This guide breaks down the process step-by-step. --- This video is based on the question https://stackoverflow.com/q/73666420/ asked by the user 'jimhomme' ( https://stackoverflow.com/u/791243/ ) and on the answer https://stackoverflow.com/a/73667761/ provided by the user 'n m' ( https://stackoverflow.com/u/10881303/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Making User Variable From config.toml Show Up In Page Body Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l... The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license. If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com. --- Understanding the Issue: Displaying User Variables in Hugo Pages When working with Hugo, a popular static site generator, many users encounter a common issue: trying to display a site-wide parameter defined in the config.toml file in the body of a page. For instance, suppose you have defined a parameter in your config.toml like this: [[See Video to Reveal this Text or Code Snippet]] You may attempt to display this variable on a page using the code: [[See Video to Reveal this Text or Code Snippet]] However, instead of seeing "Mr. Tournament Director", you are met with the raw code appearing in the output when you run the hugo server command. This can be confusing and frustrating, so let's delve into how to solve this problem effectively. The Solution: Using Hugo Shortcodes To properly display the parameter value in your pages, you will need to utilize Hugo shortcodes. These are a powerful feature that allows you to embed custom templated content easily. Here’s how to do it: Step 1: Create an Inline Shortcode First, you need to create an inline shortcode to display your variable. Here is the code to do that: [[See Video to Reveal this Text or Code Snippet]] Step 2: Enable Inline Shortcodes To use inline shortcodes as shown above, ensure that you activate them in your Hugo configuration file by adding the following line: [[See Video to Reveal this Text or Code Snippet]] This setting allows Hugo to interpret inline shortcodes correctly. Key Considerations When Implementing Using Context-Free Variables: While site.Params.tdName and .Site.Params.tdName typically yield the same result, the former is preferable because it does not rely on the context of the leading dot (.). Therefore, it creates cleaner code. Case Sensitivity in Hugo: Hugo can sometimes exhibit strange case sensitivity issues. To avoid any potential hiccups, consider renaming your parameter from tdName to td_name or tdname. Using lowercase characters ensures consistent behavior. Conclusion: Making User Variables Work for You in Hugo By following these steps, you should be able to seamlessly display the parameters you’ve defined in your config.toml in the body of your Hugo pages. Remember to leverage shortcodes effectively, pay attention to case sensitivity, and enjoy a smooth development experience while crafting your site. Now you can put these practices into action and enhance your Hugo website with user-defined variables like a pro!