go-org icon indicating copy to clipboard operation
go-org copied to clipboard

Support internal links

Open Iced-Sun opened this issue 5 years ago • 3 comments

https://orgmode.org/org.html#Internal-Links

Would go-org support the <<dedicated target>> links? Thanks.

Iced-Sun avatar Feb 29 '20 12:02 Iced-Sun

In days gone by, org-mode used to transform

* <<thing>> something
[[thing][that thing]]

into what one might expect for html:

<h2><a id="thing"></a> something</h2>
. . .
<a href="#thing">that thing</a>
. . .

I know this because I built a website using org-mode and used such anchors.

But nowadays, using org-mode 9.1.9, the result is the somewhat revolting:

<h2 id="orgb9546ca"><span class="section-number-2">1</span> <a id="org8dc48db"></a> something</h2>
<div class="outline-text-2" id="text-1">
<p>
<a href="#org8dc48db">that thing</a>
</p>

I think the older behavior was better.

plujon avatar Aug 03 '21 04:08 plujon

With GNU Emacs 26.3, in its default configuration, this:

<<target>>
[[target][link text]]

Is rendered to:

<a id="orgb4baedf"></a>
<a href="#orgb4baedf">link text</a>

Where the id is the "org" prefix plus an encoded time stamp. With Emacs, in its default configuration, each time you export to HTML the id changes. For an internal document maybe that's OK, but for an external document that others might link to... no.

So, if go-org ever supports dedicated targets, I encourage using the provided target string (properly sanitized), and leave it to the document author to avoid duplicate ids.

jmooring avatar Oct 27 '21 01:10 jmooring

:+1: [[*Header2]] and/or <<dedicated target>> support like original org-mode ("leave it to the document author to avoid duplicate ids.")

Maybe this is only news to me. It's mentioned in #52 but only in passing. internal links are currently possible albeit with more cumbersome syntax. custom_id links work both in emacs and for the go-org rendered page. I found explict examples on gohugo's discourse

* Header1
link to [[#header2id]]

* Header2
 :PROPERTIES:
:COLUMNS:  %CUSTOM_ID[(Custom Id)]
:CUSTOM_ID: header2id
:END:

dedicated target: internal link directs here

and as a link-related aside: an elisp function allowing emacs to follow go-org (hugo) valid links to other pages (like like [[/otherpage]]) as they are by hugo is described here https://kisaragi-hiu.com/links-in-both-hugo-and-org/ (advise org-element-link-parser to check current content locations as well if link is an abs path)

WillForan avatar May 14 '23 16:05 WillForan