macOS 10.13.2 High Sierra
Hugo Static Site Generator v0.31.1 darwin/amd64 BuildDate: 2017-12-04T11:43:03Z
Firefox Quantum v57.0.1
Hello. I am trying to make a quick jump facility in one of my pages.
I have used the Markdown code:
#### Index
* [How to create a script to make a new Git repository]({{<ref "#gitnew" >}})
* [How to create a script to update an existing Git repository]({{<ref "#gitadd" >}})
This appears to answer one side of the question, but I cannot figure out what needs to be put in the code further down to act as anchors for these links.
@Mikhail If Hugo generates anchors automatically for headlines how does one reference them? If one has to use the full wording of the headline, I think I would prefer the {#alpha-101} approach.
@Mikhail I had worked out how to do that, thanks! It was more the neatness, or otherwise, of the solution, that I was concerned about, though I take your later point about the SEO.
@Mikhail Yes, I am aware of that. I was simply providing a better alternative to using the HTML a tags.
You can ignore the below details, might be of interest if interested in Emacs Org mode.
The .md file I linked above, though, is autogenerated using ox-hugo (Org, Emacs). I prefer to auto-insert the anchor specifiers even though Hugo auto-generates them, to implement cross-linking features in ox-hugo… like you see the same anchor being used in the auto-generated Markdown TOC (I know that Hugo also auto-generates, but there’s a good reason for this approach too), heading anchors, and then anchor references.
Here’s the Org source that generated that Markdown:
*** Link to headings by name :toc:headings:export_option:
:PROPERTIES:
:EXPORT_FILE_NAME: link-to-headings-by-name
:EXPORT_OPTIONS: num:t toc:t
:END:
**** Alpha 101
:PROPERTIES:
:UNNUMBERED: t
:END:
- Link (with description) to a heading with section number: [[* Beta 102][Link to
/Beta 102/ heading]]
- Link (no description) to a heading without section number: [[* Zeta 103]].
The space after that =*= in the link is optional.. so this also
works: [[*Zeta 103]].
**** Beta 102
- Link (with description) to a heading without section number:
[[* Alpha 101][Link to /Alpha 101/ heading]]
***** Gamma 102.1
****** Delta 102.1.1
****** Epsilon 102.1.2
**** Zeta 103
:PROPERTIES:
:UNNUMBERED: t
:END:
***** Links (no descriptions) to headings with section numbers
- Section [[* Gamma 102.1]]
- Section [[* Delta 102.1.1]]
- Section [[* Epsilon 102.1.2]]