(defunorg-hugo-new-subtree-post-capture-template()"Returns `org-capture' template string for new Hugo post.
See `org-capture-templates' for more information."(let*(;; http://www.holgerschurig.de/en/emacs-blog-from-org-to-hugo/(date(format-time-string(org-time-stamp-format:long:inactive)(org-current-time)))(title(read-from-minibuffer"Post Title: "));Prompt to enter the post title(fname(org-hugo-slugtitle)))(mapconcat#'identity`(,(concat"\n* TODO "title" :@cat:tag:")":PROPERTIES:",(concat":EXPORT_HUGO_BUNDLE: "fname)":EXPORT_FILE_NAME: index",(concat":EXPORT_DATE: "date);Enter current date and time":EXPORT_HUGO_CUSTOM_FRONT_MATTER: :image \"/images/icons/tortoise.png\""":EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :libraries '(mathjax)"":EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :description \"this is a description\""":END:""%?\n")"\n")))(with-eval-after-load'org-capture(setqhugo-content-org-dir"~/git-repo/blog/blog-src/content-org")(add-to-list'org-capture-templates`("pe""Hugo Post (en)"entry(file,(expand-file-name"all-posts.en.org"hugo-content-org-dir))(functionorg-hugo-new-subtree-post-capture-template)))(add-to-list'org-capture-templates`("pz""Hugo Post (zh)"entry(file,(expand-file-name"all-posts.zh.org"hugo-content-org-dir))(functionorg-hugo-new-subtree-post-capture-template)))(add-to-list'org-capture-templates'("p""Hugo Post")))
Code
Inline code with ‘=’ or ‘~': =echo 123=, ~echo 456~
Code block with
1
2
3
4
5
#+begin_src cintmain(){return0}#+end_src
Images
Store all the images under $HUGO_BASE_DIR/static/ folder (except some generated images), so just include them using relative path from the org file.
You can add caption and name (for referencing purpose: as in figure 2) to an image.
You can also paste images from clipboard with org-download1. I’ve bind C-M-y to paste images, and the pasted image will be stored under path ../static/images/posts/<Level-0-Header-Name>.
Inline formulas with \$..\$. This is inline math: \(x^2 + y^2 = z^2 \frac{1}{2}\).
Displayed equations with \$\$..\$\$ or \(\LaTeX\) encironments. This is displayed math:
The code:
1
2
3
4
5
6
7
8
\begin{equation}\label{eq:1}\begin{split}
a &= b+c-d\\&\quad +e-f\\&= g+h\\&= i
\end{split}\end{equation}
will be rendered as:
\begin{equation}\label{eq:1}
\begin{split}
a &= b+c-d\\
&\quad +e-f\\
&= g+h\\
&= i
\end{split}
\end{equation}
{{< alert theme=“warning” >}}
It seems that zzo theme does not support math equation referencing and numbering yet?
{{< /alert >}}
Diagrams
Plantuml
use plantuml2 to draw, then C-c C-c to tangle the image manually (or just org export if you don’t need to customize any attributes), then you can add some attributes to the result (width, name, caption, etc.).
1
2
3
4
5
6
7
8
9
#+begin_src plantuml :file "../static/images/posts/Writing-Guide-Org/first.svg"
@startuml
title Authentication Sequence
Alice->Bob: Authentication Request
note right of Bob: Bob thinks about it
Bob->Alice: Authentication Response
@enduml
#+end_src
you can export ASCII diagrams by changing file extension to .txt (this will export diagram to a text file) or if you want to just include the ASCII diagram itself, set :results to verbatim.
1
2
3
4
5
6
7
8
9
#+begin_src plantuml :results verbatim
@startuml
title Authentication Sequence
Alice->Bob: Authentication Request
note right of Bob: Bob thinks about it
Bob->Alice: Authentication Response
@enduml
#+end_src