Hugo Markdown

Posted on  by 



Archie - Hugo theme. Archie is a minimal and clean theme for hugo with a markdown-ish UI. Forked from Ezhil Theme. Check the Demo hosted on GitHub Pages:smile:. You can find the source code to that in the site branch of this repository.

  • Basic Markdown Syntax Dillon published on 2019-12-01 included in Markdown This article offers a sample of basic Markdown syntax that can be used in Hugo content files.
  • Hugo Shortcodes are a specialized markdown syntax that can be used to extend basic markdown. Shortcodes are templates that can be called from your Hugo markdown files to add HTML snippets to the final rendered HTML. Shortcodes can be parameterized, which gives you additional flexibility and powerful reusability.

I like Markdown for its simplicity. Simplicity comes with limitations. There are some features that I miss in Markdown or it is possible to extend Markdown to support these cases, but there is no support from the Hugo side (static site generator I use).

Note: I can’t use JS to do additional rendering on the client-side, because:

  • I crosspost my articles, which means that articles should contain only HTML and images (JS will not work on 3-rd party website)
  • I care about the speed of my website and each JS script is a penalty for performance

Features

Diagrams

I would like to create diagrams with-in Markdown. Something like this:

Which would render:

Diagrams can be descirbed, for example, with: flowchart.js, js-sequence-diagrams, mermaid, PlantUML, WaveDrom, Viz.js, vega, ditaa, etc.

Support:

  • Markdown: Yes
  • Hugo: No
  • Editor preview: Yes

My workaround: use JS script which detects code-blocks with diagrams, renders them, and replaces code-blocks with the rendered images.

Euler diagrams

See examples here:

Support:

  • Markdown: Yes
  • Hugo: No
  • Editor preview: No

XKCD-style

I’d like to use XKCD-style for diagrams that are meant to illustrate something but are not based on scientific data.

For example, xkcd #1064:

Support:

Hugo Markdown Table

  • Markdown: Yes
  • Hugo: No
  • Editor preview: doesn’t matter

Math notation

I don’t need anything fancy - some greek letters, superscript, and subscript. Most of the time copy-paste Unicode characters, for example: Σ¹. But there are some edge cases, for example, there is no superscript variation for the asterisk (*).

It would be nice to use AsciiMath inside Markdown, like this:

Inline:

Which would render: Σ*

Block:

Markdown

Which would render:

Support:

  • Markdown: Possible to extend
  • Hugo: No
  • Editor preview: yes 1, 2

2-column layout

Sometimes I need to show two images side-by-side, so that reader can compare them easily. I can use a table for this, but it looks ugly (a table has a header and borders). Plus tables don’t work for code-blocks.

Support:

  • Markdown: No

Side notes

It would be nice to support side notes, like in Tufte layout. Theoretically, it is possible to reuse footnotes:

Support:

  • Markdown: Yes?
  • Hugo: No
  • Editor preview: No

Other ideas

Collspan and rowspan for tables, superscript (30^th^), subscript (H~2~O). Cobble patch landscaping jimboomba download free software.

Alternatives

Hugo

I’m considering 11ty. Also need to check pandoc.

Markdown

  • reStructuredText, see Please don’t write your documentation in Markdown
Both HTML and Markdown are supported content formats.

You can put any file type into your /content directories, but Hugo uses the markup front matter value if set or the file extension (see Markup identifiers in the table below) to determine if the markup needs to be processed, e.g.:

  • Markdown converted to HTML
  • Shortcodes processed
  • Layout applied

List of content formats

The current list of content formats in Hugo:

NameMarkup identifiersComment
Goldmarkmd, markdown, goldmarkNote that you can set the default handler of md and markdown to something else, see Configure Markup.
BlackfridayblackfridayBlackfriday will eventually be deprecated.
MMarkmmarkMmark is deprecated and will be removed in a future release.
Emacs Org-ModeorgSee go-org.
AsciiDocasciidocext, adoc, adNeeds Asciidoctor installed.
RSTrstNeeds RST installed.
Pandocpandoc, pdcNeeds Pandoc installed.
HTMLhtml, htmTo be treated as a content file, with layout, shortcodes etc., it must have front matter. If not, it will be copied as-is.

The markup identifier is fetched from either the markup variable in front matter or from the file extension. For markup-related configuration, see Configure Markup.

External Helpers

Some of the formats in the table above need external helpers installed on your PC. For example, for AsciiDoc files,Hugo will try to call the asciidoctor command. This means that you will have to install the associatedtool on your machine to be able to use these formats.

Hugo passes reasonable default arguments to these external helpers by default:

  • asciidoctor: --no-header-footer -
  • rst2html: --leave-comments --initial-header-level=2
  • pandoc: --mathjax

Because additional formats are external commands, generation performance will rely heavily on the performance of the external tool you are using. Driver for mfu hp m1005. As this feature is still in its infancy, feedback is welcome.

External Helper AsciiDoc

AsciiDoc implementation EOLs in Jan 2020 and is no longer supported.AsciiDoc development is being continued under Asciidoctor. The format AsciiDocremains of course. Please continue with the implementation Asciidoctor.

External Helper Asciidoctor

The Asciidoctor community offers a wide set of tools for the AsciiDoc format that can be installed additionally to Hugo.See the Asciidoctor docs for installation instructions. Make sure that also alloptional extensions like asciidoctor-diagram or asciidoctor-html5s are installed if required.

External asciidoctor command requires Hugo rendering to disk Xe converter pound to dollar download for mac os xoikos. to a specific destination directory. It is required to run Hugo with the command option --destination.

Markdown

Hugo Markdown Html

Some Asciidoctor parameters can be customized in Hugo:

ParameterComment
backendDon’t change this unless you know what you are doing.
doctypeCurrently, the only document type supported in Hugo is article.
extensionsPossible extensions are asciidoctor-html5s, asciidoctor-bibtex, asciidoctor-diagram, asciidoctor-interdoc-reftext, asciidoctor-katex, asciidoctor-latex, asciidoctor-mathematical, asciidoctor-question, asciidoctor-rouge.
attributesVariables to be referenced in your AsciiDoc file. This is a list of variable name/value maps. See Asciidoctor’s attributes.
noHeaderOrFooterOutput an embeddable document, which excludes the header, the footer, and everything outside the body of the document. Don’t change this unless you know what you are doing.
safeModeSafe mode level unsafe, safe, server or secure. Don’t change this unless you know what you are doing.
sectionNumbersAuto-number section titles.
verboseVerbosely print processing information and configuration file checks to stderr.
traceInclude backtrace information on errors.
failureLevelThe minimum logging level that triggers a non-zero exit code (failure).

Hugo provides additional settings that don’t map directly to Asciidoctor’s CLI options:

Hugo Markdownify

workingFolderCurrent
Sets the working directory to be the same as that of the AsciiDoc file being processed, so that include will work with relative paths. This setting uses the asciidoctor cli parameter --base-dir and attribute outdir=. For rendering diagrams with asciidoctor-diagram, workingFolderCurrent must be set to true.
preserveTOC
By default, Hugo removes the table of contents generated by Asciidoctor and provides it through the built-in variable .TableOfContents to enable further customization and better integration with the various Hugo themes. This option can be set to true to preserve Asciidoctor’s TOC in the generated page.

Below are all the AsciiDoc related settings in Hugo with their default values:

Notice that for security concerns only extensions that do not have path separators (either , / or .) are allowed. That means that extensions can only be invoked if they are in one’s ruby’s $LOAD_PATH (ie. most likely, the extension has been installed by the user). Any extension declared relative to the website’s path will not be accepted.

Hugo Markdown Code

Example of how to set extensions and attributes:

In a complex Asciidoctor environment it is sometimes helpful to debug the exact call to your external helper with allparameters. Run Hugo with -v. You will get an output like

Hugo Html

Learn Markdown

Markdown syntax is simple enough to learn in a single sitting. The following are excellent resources to get you up and running:

See Also





Coments are closed