If you need to link to any of these elements, they need to have the
#+name
keyword. The #+caption
is optional.
Below, you will find examples of the supported numbered elements, and how to link to them.
Code block (src-block
) #
#+name: code__hello
#+caption: Saying "Hello" in ~emacs-lisp~
#+begin_src emacs-lisp
(message "Hello")
#+end_src
Link to the above code block: [[code__hello]]
Table (table
) #
#+name: tab__simple_table
#+caption: Simple Table
|----------+----------+----------|
| Header 1 | Header 2 | Header 3 |
|----------+----------+----------|
| abc | def | ghi |
|----------+----------+----------|
Link to the above table: [[tab__simple_table]]
Figure #
#+name: fig__some_figure
#+caption: Some Figure
[[./images/some_figure.png]]
Link to the above figure: [[fig__some_figure]]
See Image Links for more details.
Auto-prefixing element type names in links #
When links are made to any of these numbered elements, ox-hugo
has
an option to prefix the link descriptions with that element’s type
name.
Element Type | Prefix (en) |
---|---|
src-block or code block |
Code Snippet |
table |
Table |
figure1 | Figure |
To enable this auto-prefixing feature, set
org-hugo-link-desc-insert-type
to a non-nil value.
(with-eval-after-load 'ox-hugo
(setq org-hugo-link-desc-insert-type t))
This feature has language support too. If the #+language
keyword is
set to a language code other than en
(example: de
), the
translations of the element type names get exported. The translations
are based on the org-export-dictionary
variable from ox.el
.
-
“figure” is not exactly a proper “Org element”. A “figure” is a standalone figure link in an Org paragraph. ↩︎