obsidian-digital-garden icon indicating copy to clipboard operation
obsidian-digital-garden copied to clipboard

Heading links do not remove the hashtag character

Open ThatOtherAndrew opened this issue 2 years ago • 5 comments

If you have a link to a heading in a document such as the following:

[[#heading]]

Then it renders as #heading instead of heading.

ThatOtherAndrew avatar Nov 09 '22 17:11 ThatOtherAndrew

I'm not sure what the expected behavior is but I did create a test page to play with this.

https://hive.mod0.org/tech/obsidian/test-heading-links/

I rarely use these features in Obsidian and so don't have many opinions, especially for how it should work in a Digital Garden website context. I thought having a recent rendering of current behavior might assist in clarifying the issue here.

@ThatOtherAndrew, can you provide more details that might lead to a feature request or bug report? Otherwise, in a quest to help reduce open issues for this epic tool, we consider closing this issue.

Context: I'm just a fan/user of this tool who cares about long-term sustainability of this project so trying to help reduce or clarify the backlog of issues where I can.

dayne avatar Oct 17 '23 07:10 dayne

I didn't open a new issue because I saw this one, but I believe I can explain it better. Obsidian supports three types of internal links:

  1. [[Other note]] → works
  2. [[Other note#Subtitle]] → works, links to a specific section of the other note.
  3. [[#Subtitle]] → doesn't work, is supposed to link to a different section of the file you're currently in.

Actually, the proper link does get created, but it's empty. Here's HTML of my example in which I simply call [[#Positive factors]]:

<p>
    <a class="internal-link" data-note-icon="" href="/note-i-m-currently-in/#positive-factors"></a>
    <a class="tag" onclick="toggleTagSearch(this)" data-content="#Positive">#Positive</a> factors
</p>

So instead of linking to a section in the file named "Positive factors", it:

  1. Creates an empty (but currect) link.
  2. Interprets "#Positive" as a tag and links to a search.
  3. Interprets "factors" as just a normal text.

A workaround I found is to use the longer version ([[Note I'm currently in#Positive factors]]), which is a bit annoying but it does work.

I believe that src/helpers/linkUtils.js in the template doesn't account for links beginning with a hashtag, but I don't know if that's the only thing it's missing, some change might be needed in the extension as well.

inputsh avatar Oct 17 '23 08:10 inputsh

Sorry, I realise how rubbish my issue was! What @inputsh said is spot on.

ThatOtherAndrew avatar Oct 17 '23 10:10 ThatOtherAndrew

Still there and still is a problem. Instead of link to the heading a link to a tag is created.

neoromantic avatar Feb 17 '24 19:02 neoromantic

I previously saw this issue after an update [#411] and never managed to get it to go away in the subsequent updates. I re-did my stactic layout and switched over to Vercel, thinking that a fresh start might solve my 404 pages issue, but it looks like it is still going strong — including all of the links-to-subheaders that used to work now being broken as well.

delphictruth avatar Jun 15 '24 04:06 delphictruth