# Better topic map top link title for links to categories

**URL:** https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375
**Category:** UX
**Tags:** pr-welcome, topic-map
**Created:** [July 18, 2017, 10:17am UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375 "2017-07-18T10:17:36Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![rriemann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rriemann/32/115238_2.png) [@rriemann](https://meta.discourse.org/u/rriemann)
#### Post date: [July 18, 2017, 10:17am UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/1 "2017-07-18T10:17:36Z")

</div>

Hello,

let’s say I link to a category: #Contribute > Feature

The topic map top link will read `/c/feature` or something like that. It would be nicer to have a title like `Feature Category`.

PS: I noticed this in a private message.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [July 18, 2017, 12:22pm UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/2 "2017-07-18T12:22:25Z")

</div>

I don’t understand what the “The topic map top link” is

---

<div class="post-metadata">

### Author: ![rriemann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rriemann/32/115238_2.png) [@rriemann](https://meta.discourse.org/u/rriemann)
#### Post date: [July 18, 2017, 12:23pm UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/3 "2017-07-18T12:23:42Z")

</div>

> [@erlend\_sh](#):
>
> I don’t understand what the “The topic map top link” is

I have found that name somewhere in the forum. Here, it is under the caption “Popular Links”:

> ![](https://global.discourse-cdn.com/meta/original/3X/d/2/d2f22e4ca1b87a6c2bc5d1a73cac7c951de40d8f.png)

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [July 18, 2017, 12:25pm UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/4 "2017-07-18T12:25:41Z")

</div>

Aaah okay. Yeh changing that title might make make sense.

---

<div class="post-metadata">

### Author: ![kasiabulat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kasiabulat/32/86402_2.png) [@kasiabulat](https://meta.discourse.org/u/kasiabulat)
#### Post date: [October 30, 2017, 8:02am UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/5 "2017-10-30T08:02:21Z")

</div>

Hi! I’m new to Discourse and it is the first open source project I’m working on. Can I take this issue as my starter-task? I think it will help me to get to know the project.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [October 30, 2017, 8:40am UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/6 "2017-10-30T08:40:26Z")

</div>

Sure, go for it 👍 Do not hesitate if you need help.

---

<div class="post-metadata">

### Author: ![kasiabulat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kasiabulat/32/86402_2.png) [@kasiabulat](https://meta.discourse.org/u/kasiabulat)
#### Post date: [November 5, 2017, 6:01pm UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/7 "2017-11-05T18:01:26Z")

</div>

Thank you! I found the place, which needed a change, edited the code and created a pull request: [UX: better topic map top link title for links to categories by kasiabulat · Pull Request #5289 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/5289).

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 15, 2017, 1:05am UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/9 "2017-11-15T01:05:36Z")

</div>

Hi @kasiabulat I was just reviewing this and sadly this is bit complicated, especially when localization is considered.

The bug here is the the `title` field in TopicLink is not being populated for these internal category links, the fix is fully server side not client side.

I did remove #starter-task from here cause it is somewhat complicated, but if you feel like giving it a shot again on the server side let me know … so sorry I need to close the open PR I feel extra bad about it. We should have guided you properly.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 15, 2017, 1:06am UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/10 "2017-11-15T01:06:40Z")

</div>

I would just suppress category links from the topic map. I don’t think they add a lot. That would also be an easier PR I think @sam?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 15, 2017, 1:11am UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/11 "2017-11-15T01:11:32Z")

</div>

Marginally, cause only easy fix is to suppress all internal links, you don’t really want to write yet another route matcher client side.

We could suppress all internal links that don’t have a title, that would be somewhat easier, but then what if you link to TOS or something else that is important.

Lets test this out: [https://meta.discourse.org/tos](https://meta.discourse.org/tos), [Privacy policy | Discourse - Civilized Discussion](https://meta.discourse.org/privacy), [/faq](https://meta.discourse.org/faq)

Hmmm: yeah

`<a class="hashtag" href="/c/2-feature">#<span>feature</span></a>` yeah this thing needs a title which our CommonMark engine should provide and then a proper fix would flow.

Wow this is pretty messy for internal links:

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/9/39894be82264dd9b093007f247c4912eb92707d5.png)

looks like mini onebox is not setting title…

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 15, 2017, 1:26am UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/12 "2017-11-15T01:26:13Z")

</div>

Yeah simply adding title for internal links would be best there. I think you meant to say ‘topic map’ in your last sentence as well?

---

<div class="post-metadata">

### Author: ![kasiabulat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kasiabulat/32/86402_2.png) [@kasiabulat](https://meta.discourse.org/u/kasiabulat)
#### Post date: [November 17, 2017, 2:51pm UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/13 "2017-11-17T14:51:47Z")

</div>

OK, so I think I would like to coutinue working on it. Can you give me some tips on where can I begin and somehow summarize what should be done?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 17, 2017, 7:59pm UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/14 "2017-11-17T19:59:39Z")

</div>

@eviltrout may be able to advise he worked on it last.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 17, 2017, 8:38pm UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/15 "2017-11-17T20:38:20Z")

</div>

Simplest change is to amend [https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/discourse-markdown/category-hashtag.js.es6](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/discourse-markdown/category-hashtag.js.es6) it is already covered in tests, so they will need changing

---

<div class="post-metadata">

### Author: ![kasiabulat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kasiabulat/32/86402_2.png) [@kasiabulat](https://meta.discourse.org/u/kasiabulat)
#### Post date: [November 20, 2017, 8:29pm UTC](https://meta.discourse.org/t/better-topic-map-top-link-title-for-links-to-categories/66375/16 "2017-11-20T20:29:26Z")

</div>

Thanks for the tip. Well, I could change the line 11: `token.attrs = [['class', 'hashtag'], ['href', result[0]]]` (in [https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/discourse-markdown/category-hashtag.js.es6](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/discourse-markdown/category-hashtag.js.es6)), so that there is also title added as an argument (I guess that there is a funtion that changes slug to the category name, but I haven’t found it yet). If I do it that way, hashtags to new created categories (not all of them, so I think it doesn’t satisfy us) will look something like: `<a class="hashtag" href="/c/1-category-name" title="Category Name">#<span>category-name</span></a>` in post replies. And then what will be needed is getting this title out of the attributes and showing it the post summary (topic map). But the title from attributes is null for these hashtags in the place I tried to change in my previous pull request ([discourse/app/assets/javascripts/discourse/widgets/topic-map.js.es6 at 3b7128102c12d72d0303c83e4f113aa06c23655c · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/3b7128102c12d72d0303c83e4f113aa06c23655c/app/assets/javascripts/discourse/widgets/topic-map.js.es6), call of the function createWidget creating topic-map-link widget, line 127), so this title is probably changed by some other functions earlier and for now I don’t know how exactly it flows. Should I dig into it and analyze how it all works? And please correct me if I don’t undestand something in what I described.
