Snorlax Ƶƶ( ̄▵—▵ ̄)

Write a Hugo Shortcodes to embed Telegram post

Create your own Shortcodes to Embed Telegram post.

You can extend Hugo’s built-in shortcodes by creating your own using the same templating syntax as that for single and list pages.

Hugo documents

File Location

To create a shortcode, place an HTML template in the layouts/shortcodes directory of your source organization. Consider the file name carefully since the shortcode name will mirror that of the file but without the .html extension.

telegramPost.html

Create telegramPost.html inside layouts/shortcodes

<div id="tgPost">
  <script type="text/javascript"></script>
  <script
    async
    src="https://telegram.org/js/telegram-widget.js?15"
    data-telegram-post="{{ .Get 0 }}/{{ .Get 1}}"
    data-width="100%"
  ></script>
</div>

layouts/shortcodes/telegramPost.html will be called with{{< telegramPost channelName PostId >}}

For instance:

{{< telegramPost programmerjokes 2246 >}}

Reference

Create Your Own Shortcodes

A way to mark plain-text and stop hugo from interpreting?

#WeChat