Site Editing Cheatsheet
2023-01-26
math mode
math: true
enable block on page, powered by KaTeX.js
syntax
inline mode
The quadratic polynomial \\(ax^2 + bx + c \\) has discriminant \\(b^2 - 4 a c\\).
will produce
The quadratic polynomial has discriminant .
display mode
achieved this by katex shortcode .
{{< katex >}}
x_{1,2} = \frac{ - b \pm \sqrt{b^2 - 4ac} }{ 2a }
{{< /katex >}}
will produce
The quadratic formula for the roots of the quadratic polynomial:
table of contents
enable toc on page.
show_toc: true
escaping hugo shortcode
change your shortcode from
{{< year >}}
to
{{< /*year*/ >}}
table
Has 3 optional arguments, id
, class
and title
.
{{< table title="Environment" class="table mx-auto border border-slate-500" >}}
| key | value |
| ---- | --------- |
| host | localhost |
{{< /table >}}
Click to Open
hugo-shortcode-table.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ $htmlTable := .Inner | markdownify }} | |
{{ $label := i18n "table_label" | default "Table" }} | |
{{ $tag := "<table>" }} | |
{{ $newTag := "<table" }} | |
{{ with .Get "id" }} | |
{{ $newTag = printf "<table id='%s'" . }} | |
{{ end }} | |
{{ with .Get "class" }} | |
{{ $newTag = print $newTag " " . }} | |
{{ end }} | |
{{ $newTag = print $newTag " itemscope itemtype='https://schema.org/Table'>" }} | |
{{ with .Get "title" }} | |
{{ $caption := printf "<caption itemprop='about'><strong>%s</strong> %s</caption>" $label . }} | |
{{ $newTag = print $newTag $caption }} | |
{{ end }} | |
{{ $htmlTable := replace $htmlTable $tag $newTag }} | |
{{ $htmlTable | safeHTML }} | |
{{/* inspire by https://gist.github.com/djibe/7a8ba9516f4495dbd6fdf1d1de7a60fe#file-hugo-shortcode-table-html and improved by kuaz */}} |
details
Creates a details HTML element. You can pass your title to summary element to setup title
argument.
Has 3 arguments:
open
: should detail element be open or not.title
: title after element summary.markdownify
: use markdownify or not. true to pass raw html to detail.
{{< details title="\*Hello, Planet." >}}
[[Official]*ハロー、プラネット。](https://www.youtube.com/watch?v=oVb6Gkf-IJM)
{{< /details >}}
will produce
Click to Open *Hello, Planet.
[Official]*ハロー、プラネット。Click to Open
hugo-shortcode-details.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ $open := .Get "open" | default "false" }} | |
{{ $markdownify := .Get "markdownify" | default "true" }} | |
<details | |
{{ if eq $open "true"}} | |
open | |
{{ end }} | |
> | |
<summary> | |
{{ i18n "click_to_open" | default "Click to Open" }} | |
{{ with .Get "title" }} | |
{{ . | markdownify }} | |
{{ end }} | |
</summary> | |
{{ if eq $markdownify "true"}} | |
{{ .Inner | markdownify }} | |
{{ else }} | |
{{ .Inner }} | |
{{ end }} | |
</details> |
gist
A simple gist shortcode.
{{< gist author="exkuretrol" hash="88a4dfda6f4f25dc09c6ab472f4a44bb" >}}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script | |
src={{ printf "https://gist.github.com/%s/%s.js" (.Get "author") (.Get "hash") }} | |
></script> |