Closed vinurs closed 2 years ago
Can you share the complete Org file with which I can reproduce that error?
My gut feeling says that the "Header 1" section is missing the "header1" CUSTOM_ID.
# -*- mode: org; -*-
#+hugo_base_dir: ~/sys-cfg/github/vinurs.github.io/
#+hugo_section: ../content/post/pkms
#+startup: show2levels
* Table Of Content :TOC:
- [[#header1][header1]]
- [[#history][history]]
- [[#footnotes][Footnotes]]
* header1
:PROPERTIES:
:export_title: header1
:export_description: header1
:export_author: vinurs
:export_email: <haiyuan.vinurs@gmail.com>
:export_date: 2021-04-13
:export_hugo_categories:
:export_hugo_tags: tag1 tag2
:export_hugo_draft: true
:export_file_name: 20d57dce-9330-4d45-b62f-3c74074a91dd
:export_hugo_auto_set_lastmod: t
:export_hugo_expirydate: 2999-01-01
:export_hugo_front_matter_key_replace: description>summary
:export_hugo_custom_front_matter: :from orgmode
:END:
hello, this is a test 11
#+hugo: more
babababaa
** history
*** 2021/04/13
+ draft
* Footnotes
* COMMENT Local Variables :ARCHIVE:
# Local Variables:
# eval: (org-hugo-auto-export-mode -1)
# End:
[[#header1][header1]]
The link uses the #
notation. So the Org exporter will expect some Org heading with CUSTOM_ID
property set to header1
. I believe you will see the same error using any exporter because the error is not specific to ox-hugo.
You might already know this, but you don't need a separate package to create that TOC; you can just use the Org #+toc
keyword. You can find the documentation at https://ox-hugo.scripter.co/doc/org-toc/ .
[[#header1][header1]]
The link uses the
#
notation. So the Org exporter will expect some Org heading withCUSTOM_ID
property set toheader1
. I believe you will see the same error using any exporter because the error is not specific to ox-hugo.
yes, this Table Of Content
is auto generated by :TOC:
for me, there is no need to export the toc, i use the toc
section is that i want to see all toc in this file when i write sth in this file
it's not ox-hugo's problem
yes, this Table Of Content is auto generated by :TOC:
Correct, but that's using an external org-toc
package. I meant to say that you don't need that if you want toc in the export.
Looking at https://github.com/alphapapa/org-make-toc, I think that it generates a TOC that's friendly with Org parsing on GitHub.. the generated TOC is not Org export friendly unless that package also inserts the CUSTOM_ID tag for each heading.
cc: @alphapapa Is my above understanding correct?
@vinurs
there is no need to export the toc
In that case, you can add noexport
tag to that TOC heading.
@vinurs This works
#+hugo_base_dir: .
* Table Of Content :TOC:
- [[#header1][header1]]
- [[#history][history]]
- [[#footnotes][Footnotes]]
* header1
:PROPERTIES:
:export_title: header1
:custom_id: header1
:export_description: header1
:export_author: vinurs
:export_email: <haiyuan.vinurs@gmail.com>
:export_date: 2021-04-13
:export_hugo_categories:
:export_hugo_tags: tag1 tag2
:export_hugo_draft: true
:export_file_name: 20d57dce-9330-4d45-b62f-3c74074a91dd
:export_hugo_auto_set_lastmod: t
:export_hugo_expirydate: 2999-01-01
:export_hugo_front_matter_key_replace: description>summary
:export_hugo_custom_front_matter: :from orgmode
:END:
hello, this is a test 11
#+hugo: more
babababaa
** history
:PROPERTIES:
:custom_id: history
:END:
*** 2021/04/13
+ draft
* Footnotes
:PROPERTIES:
:custom_id: footnotes
:END:
@vinurs This works
#+hugo_base_dir: . * Table Of Content :TOC: - [[#header1][header1]] - [[#history][history]] - [[#footnotes][Footnotes]] * header1 :PROPERTIES: :export_title: header1 :custom_id: header1 :export_description: header1 :export_author: vinurs :export_email: <haiyuan.vinurs@gmail.com> :export_date: 2021-04-13 :export_hugo_categories: :export_hugo_tags: tag1 tag2 :export_hugo_draft: true :export_file_name: 20d57dce-9330-4d45-b62f-3c74074a91dd :export_hugo_auto_set_lastmod: t :export_hugo_expirydate: 2999-01-01 :export_hugo_front_matter_key_replace: description>summary :export_hugo_custom_front_matter: :from orgmode :END: hello, this is a test 11 #+hugo: more babababaa ** history :PROPERTIES: :custom_id: history :END: *** 2021/04/13 + draft * Footnotes :PROPERTIES: :custom_id: footnotes :END:
wow, thanks very much ^_^
@vinurs Just to close the loop, also see https://github.com/alphapapa/org-make-toc#known-issues.
add noexport
like this?
* Table Of Content :TOC: :noexport:
- [[#header2][header2]]
- [[#history][history]]
- [[#footnotes][Footnotes]]
it seems it has no effect
That's wrong way of appending tags to a heading. The right way is this:
* Table Of Content :TOC:noexport:
- [[#header2][header2]]
- [[#history][history]]
- [[#footnotes][Footnotes]]
But, you are right. I just realized that that will not solve this problem, because the org link sanity check happens in the entire Org document at the beginning of export.
The only solution is to fix the links by adding the CUSTOM_ID properties.
yes, so the more troublesome thing is that when i modify the header, i must modify two places(header and custom id) at the same time
it's strange, i set the :noexport:
tag, and i didn't set any custom_id
, i run org-hugo-export-to-md
the org file can export to md file, why run make md
can not
the toc-org has a QUOTE
tag that generate the following toc,
* Table Of Content :TOC:QUOTE:noexport:
#+BEGIN_QUOTE
- [[#header3][header3]]
- [[#history][history]]
- [[#footnotes][Footnotes]]
#+END_QUOTE
why run make md can not
Because the ox-hugo exporter ensures that all Org links in the buffer are valid, so that internal linking works in ox-hugo exports.
when i modify the header, i must modify two places(header and custom id) at the same time
If you do this frequently, you should come up with a small interactive elisp function like change-current-org-header
that does these:
in the org file i have a section like this
i use the org-toc update this section, when
make md
, it shows