Pictures

The author as a younger man
I did a thing and it got posted.
If you think tacos are the crunchy shells with ground beef in them, please expand your horizons. These al pastor tacos were as hot as lava and divine. pic.twitter.com/Mad4eqpYmZ
— Dylan Thomas (BitsByMe@hachyderm.io) (@dvhthomas) August 12, 2021
Link to a post
By reference:
Or a specific link in a page. This uses the fact that markdown adds an automatic ref to titles:
Link to GitHub repo files
Use the github shortcode to link to files in your GitHub repository. The repo URL is configured in config.toml as params.githubRepo.
Basic usage (defaults to main branch):
| |
Link to a specific branch:
| |
Link to content files:
| |
This generates URLs like https://github.com/dvhthomas/blog/blob/main/blog.go.
A gist on Github
Code snippet
If you include code inline you also get the ability to highlight lines:
| |
But practically speaking it may be easier to include code from files that live in the same directory as the index.md for each post.
For example the file hello.py is in the same directory as tips.md.
We can display it using
hello.py
| |
Diagrams
Mermaid
The YAML front matter contains mermaid: true and then this will render a nice diagram.
D2
D2 is a modern diagram scripting language. Create a .d2 file in the same directory as your post, then reference it using the d2 shortcode.
For example, here’s a simple workflow diagram defined in example.d2:
The D2 source looks like this:
start -> process: step 1
process -> end: step 2
Reference it in your markdown with:
{{< d2 src="example.d2" >}}
Include an optional width: xx% to control the diagram’s width. For example:
{{< d2 src="example.d2" width="85%" >}}
Controlling diagram width
By default, D2 diagrams scale to 70% of the container width. You can override this with the width parameter:
- Default (70%):
{{< d2 src="diagram.d2" >}} - Full width (100%):
{{< d2 src="diagram.d2" width="100%" >}} - Half width (50%):
{{< d2 src="diagram.d2" width="50%" >}} - Custom:
{{< d2 src="diagram.d2" width="85%" >}}
Use wider widths for complex flow diagrams, and narrower widths for simple hierarchical diagrams.
Reference URLs
You can avoid typing a URL multiple times by using a reference-type URL. Use either a numbered footnote style for whatever text. Or specific text that matches the link text itself.
Math
Set mathjax: true in the front matter.
Then use either the ${inline}$ for or block form using two \$\$:
$$\large CAGR = \left( V_{final} \over V_{begin} \right)^{1/t} - 1 $$
Construct formulae using the $\LaTeX{}$ reference for math.
Use the great reference on Overleaf for lots of worked examples.
And this StackExchange Math articles is superb.
Charts
Using vega-lite.
Create a .json file with your Vega-Lite specification in the same directory as your index.md, then reference it using the vega shortcode.
For example, this chart references tips.json in the same directory:
The shortcode takes two parameters:
id: A unique ID for the chart div (e.g.,viz,chart1, etc.)spec: The filename of the JSON spec in your page directory (e.g.,tips.json)
No front matter configuration needed - the shortcode is self-contained and loads Vega-Embed automatically.