# Auto-linking of subtrees

**URL:** <https://org-roam.discourse.group/t/auto-linking-of-subtrees/2798>\
**Category:** Requests\
**Created:** [October 8, 2022, 5:42pm UTC](https://org-roam.discourse.group/t/auto-linking-of-subtrees/2798 "2022-10-08T17:42:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xa7fd3b](https://avatars.discourse-cdn.com/v4/letter/0/85e7bf/32.png) [@0xa7fd3b](https://org-roam.discourse.group/u/0xa7fd3b)\
**Post date:** [October 8, 2022, 5:42pm UTC](https://org-roam.discourse.group/t/auto-linking-of-subtrees/2798/1 "2022-10-08T17:42:58Z")

</div>

Apologies if this is already documented somewhere, but I have looked around and can’t find out whether this is possible: I often organize my simple TODOs and tasks into sub trees in a single file, like this:

```nohighlight
* Tasks
** Clean house
** Buy groceries
** Pay bills

```

This is also how the default `org-journal` organizes things:

```nohighlight
* 2022
** 2022-10 October
*** 2022-10-07 Friday
My journal entry for today.
*** 2022-10-08 Saturday
My journal entry for today.

```

I’m aware for the second use case that there’s the org roam dailies feature, but for simple things I like to keep everything in one file so I can search it and see it all on one screen. (For more complex notes or nested ideas I’m a fan of the one-note-per-file idea.)

The trouble is, on the org-roam graph, if the children have IDs, I’d like them to show up as a link from the parent node. Currently they show up as orphans so it’s hard to tie in visually “these are all the things related to topic X”. I can accomplish what I want by scripting link insertion into either the parent or children, but that clutters the buffer.

Is there a way to configure a node so that it gets automatically generated links pointing to all its direct children?

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 9, 2022, 2:50pm UTC](https://org-roam.discourse.group/t/auto-linking-of-subtrees/2798/2 "2022-10-09T14:50:16Z")

</div>

Is this the same issue for Org-roam-UI?

> <https://github.com/org-roam/org-roam-ui/issues/67>
>
> When using the test file below, I am seeing some node are linking to nodes in ot…her subtree, for example in the screenshot below we see that the \`Read Note 2\` which has an olp of \`("Headline" "Second Again")\` is being linked to the \`Another\` node with the \`:good:\` tag when it should be linked directly to the \`Headline\` node.
> 
> It seems there isn't a check for if the parent node is in the child notes olp.
> 
> !\[Screenshot from 2021-08-16 11-37-16\](https://user-images.githubusercontent.com/10950530/129590382-baaafedb-8317-49d5-8588-0f89994f6251.png)
> 
> Other than that, it seems to correctly handle the edges this file presents. There should probably be a test written based on this file to make sure there aren't regressions in the hierarchical inference.
> 
> \`\`\`
> :properties:
> :ID: 18434726-762e-42d7-9042-3f71454248b5
> :end:
> \#+title: test
> \#+startup: latexpreview inlineimages
> 
> \#+begin\_src elisp
> (setq org-use-tag-inheritance 'nil)
> \#+end\_src
> 
> \* Headline
> :properties:
> :ID: 3d56e3ad-e9f1-405c-b308-306a86cac7b8
> :end:
> \*\* Another :bad2:
> :properties:
> :ID: a4e471b2-3dc3-4061-acde-f73bc7b73773
> :end:
> \*\* Another :good:
> :properties:
> :ID: 7605a32c-81f8-45af-9496-702c803c16b1
> :end:
> \*\*\* Another :bad3:
> :properties:
> :ID: 72d7686f-ceed-47f6-98bb-59d5f5bfb94b
> :end:
> \*\*\* Real Note
> :properties:
> :ID: 1b242d67-5da1-4159-963b-137df2b03a5d
> :end:
> \*\* Second Again
> \*\*\* Read Note 2
> :properties:
> :ID: 28481dd7-ce04-4d8b-a264-f5933c119bf1
> :end:
> \*\* Another :bad:
> :properties:
> :ID: 5004d23d-4c63-4930-9979-1fadd7a8ff65
> :end:
> \`\`\`

---

<div class="post-metadata">

**Author:** ![0xa7fd3b](https://avatars.discourse-cdn.com/v4/letter/0/85e7bf/32.png) [@0xa7fd3b](https://org-roam.discourse.group/u/0xa7fd3b)\
**Post date:** [October 9, 2022, 3:12pm UTC](https://org-roam.discourse.group/t/auto-linking-of-subtrees/2798/3 "2022-10-09T15:12:12Z")

</div>

It’s the same issue, yes – but with your pointer I found a resolution!

The above logic from that bugfix only kicks in if the file itself has a properties node ID at the root of the file. If I just add that everything works as I expect and want. This seems like it’s technically a minor bug but not one I’m really bothered by. Thanks for the help @nobiot!
