Emacs org-mode: org to html conversion - link to a section on another page?

How can I link to and exit a section of a separate page in org-mode in html? For example, if in file.org I have a label for section X:

** Section X
#+LABEL: sec:X

I can refer to this section with [[sec:X][section X]]in the .org file. I can link to file.org [[file:file.org][link to file.html]]from an external document (and will be automatically linked to the corresponding html file when published). But outside this document, I cannot refer to section X as [[file:file.org#sec:X][link to section X of file.html]], because the section label is converted to numbers (for example, sec-3_1). Therefore, I would have to refer to it as [[file:file.html#sec-3_1][link to section X of file.html]], but it is assumed that I know that the label sec:Xwill be converted to sec-3_1...

(I use the default functions used with org-publish-projectto convert.)

+3
source share
1 answer

From: http://orgmode.org/manual/External-links.html#External-links

file:sometextfile::NNN                    file with line number to jump to
file:projects.org                         another Org file
file:projects.org::some words             text search in Org file
file:projects.org::*task title            heading search in Org file

Edit: Better to use the "CUSTOM_ID" property, for example

  file1.org
  -------------

  * Section
    :PROPERTIES:
      :CUSTOM_ID: my_section_link_id
    :END:

Then in file2.org where you want to set the link to file1.org:Section

  * Sectoin In File2
    - Link to [[file:file1::my_section_link_id][Section]] in File1

I think there is an error in orgmode 7.4 where, if you use "file: file1 :: # my_section_link_id", it generates the wrong html link, but the correct org link. If you use "file: file1 :: my_section_link_id", it generates the correct html link, but the incorrect org link.

+4
source

Source: https://habr.com/ru/post/1783071/


All Articles