-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using headline slug as anchor breaks some features #88
Comments
That's an interesting case. I don't use TOC with Hugo exports, as Hugo generates one automatically.
I can make that an option, but not enabled by default. But as you said, I didn't do that in the first place as I don't want to mess with the source Org file. Btw, before I do this, can you create a branch with a test for this, with the expected .md file? That way when I export it, git diff shows me the difference between the actual and the expected export. Also, would it help if that function can go in before export hook? If that works, we can add this to the manual. Either way, let's start with the test case. :) |
Just a thought.. may be temporarily advice the Org toc generation logic .. |
I strongly believe that we shouldn't be modifying the Org file in
Thinking further, this problem is a 2-part problem:
Try out the support-org-toc branch; this aims to fix part 1 of the problem above. Regarding part 2 of the problem, it is closely related to #30. WDYT? Force-setting the |
Are you referring to this, when you say you rely on Hugo TOC feature? This appears to be a template level feature - Do you have a special template for posts which need a TOC?
I shall try this out, and let you know what I find.
Yes, it does seem related to #30, but I'm not sure how closely. The TOC is generated dynamically, and so I'm guessing the solution would be quite different from replacing links as discussed in the mailing list for #30. Also, links which link to headlines in the current post are also broken --
I completely agree with you on this. |
I realize I could either change my template to include the TOC conditionally, based on some metadata in the post, or create a short code that I can include in posts. But, I find the org TOC to provide much more granular control. |
I just rely on an inverse Page param in my custom theme. By default, I always insert the TOC.. unless I have set a Page param
Right, but once I figure out how to intercept that internal link insertion, I just need to call
I believe these can be fixed once I know how to intercept at the right point and make |
Yes, I do just that.. I have put a bunch of reference links in my earlier reply.
I agree.. I hope that this test branch at least resolves the TOC issue. |
(I just force-pushed by mistake (just a rebase) to support-org-toc branch, FYI.) |
This seems to work well for me. 👍 |
Thanks for confirming, I'll merge the branch today. As a side, would you consider publishing the Org source of your blog too? I am thinking of adding mentions of |
👍
I have considered that, given that the sources of my blog were public previously. But, I really like the fact that keeping the org file private allows me to write and have as many draft/unpublished posts as I like in the org source file. I could possibly write a script to copy over the org sources of all the published posts to a different file, and publish that, though. |
I do that too! But I use hunk staging using Magit to commit only the part of the Org file I want :) |
Done. You can find the source file here: https://github.com/punchagan/punchagan.muse-amuse.in/blob/master/content-org/all-posts.org |
The TOC feature is now merged into master in f0fa731. Documentation: https://ox-hugo.scripter.co/doc/org-toc/ |
@punchagan From your earlier post:
Org heading-based internal linking now works without having having to set This was fixed in this commit (a89fb81). See the same commit for Org example. And here's the Hugo rendered test: https://ox-hugo.scripter.co/test/posts/link-to-headings-by-name/ |
Hi, how this function work? it seems not working in my case. |
@ChloeZhou1997 What function are you referring to? Your quoted text just says that linking to Org headings works. |
We use
org-hugo-slug
to create a custom anchor for headlines. This creates readable, consistent anchors for headlines which don't change between exports, which is nice.But, this breaks the TOC keyword.
I wonder if it would be a good idea to add the slugs as custom ids to headlines. Something like what these helper functions do.
Having these custom ids set makes it easier to link to headlines within a post using the org internal links mechanism for headlines, and also fixes the TOC keyword to work correctly.
I think it may not be a good idea for the export functions to modify the files they are exporting, but it would be nice to have the creation of these custom ids happen automatically somehow. May be add them as an after/before save hook?
The text was updated successfully, but these errors were encountered: