芒果芒果🥭

个人博客

Feb 14, 2021 - 2 minute read - Hugo Shortcodes

Shortcodes In Action

The theme’s short codes in action. See my shortcode repository at https://github.com/parsiya/Hugo-Shortcodes for more.

Table of Content

Use the short code to put it anywhere in the page like this:

{{ < toc > }}

If you are using Goldmark, you need to change the start and end level headings in the config file. The defaults are level 2 and 3 respectively.

[markup]
  [markup.tableOfContents]
    endLevel = 8
    startLevel = 1

Please see more at https://gohugo.io/getting-started/configuration-markup/#table-of-contents.

The table of contents for this page:

Codecaption

Python

Python code highlight
1
2
3
4
5
from base64 import b64encode
from binascii import unhexlify

print b64encode(unhexlify("0a0b0c0d"))
CgsMDQ==

Using a codefence (```):

from base64 import b64encode
from binascii import unhexlify

print b64encode(unhexlify("0a0b0c0d"))
CgsMDQ==

Using the Hugo internal highlight shortcode:

from base64 import b64encode
from binascii import unhexlify

print b64encode(unhexlify("0a0b0c0d"))
CgsMDQ==

Using an indented code block (no highlighting):

from base64 import b64encode
from binascii import unhexlify

print b64encode(unhexlify("0a0b0c0d"))
CgsMDQ==

In a Github gist:

Go

Go highlight
1
2
3
4
5
6
7
8
9
package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello World")
}

Powershell

Hello
1
2
3
4
5
6
# notepad does not have an entry
$ Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\notepad.exe"
False
# chrome does
$ Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe"
True

imgcap

The national parks preserve wild life The national parks preserve wild life

Image is named The national parks preserve wild life. Acquired from the Library of Congress’ “Free to Use and Reuse: Work Projects Administration (WPA) Posters” collection at https://www.loc.gov/item/98518597/.

The same image using the markdown image tag.