How to remove "Website Name" links shared in a topic/post?

When I add an internal link on my Discourse instance like…
https://MyWebsite.com/t/MyCategory

It will resolve to a more user friendly link that looks like…

My Category - My Website Name

  • Notice how it includes - My Website Name

But when I post an internal link from Meta.Discourse.org in the Meta Discourse instance, It does not include - Meta Discourse as shown below.

Category definition for Feature

How can I achieve this on my own Discourse instance? I dont want - Meta Discourse or - My Website Name from showing in these resolved links.

Thanks!

UPDATE

  • I have changed the links above to better represent my question.

SOLVED

The reason why the Meta Discourse link does not show - Meta Discourse and my website link does, is because my website link is for a category, while the meta.discourse link is for a topic as @supermathie has pointed out.

To combat this issue on my own website, I will simply use
[My Category](https://MyWebsite.com/t/MyCategory) markdown to avoid it adding the - My Website Name to the end of it. as @Heliosurge has pointed out.

Thanks both for your helpful input!

4 Likes

Intra-site topic links to the same site don’t include the category or site name:

same site, topic: Category definition for Feature

same site, category: feature - Discourse Meta

different site, topic: Category definition for Gaming - gaming - Demo

different site, category: gaming - Demo

vs. the same on Try:

(as to how you can change that, I’m not sure where that is, but that’s why it’s different)

3 Likes

Is the link being used internal use?

There is also an option to Wrap Text in [Text]followed by the link wraped in “(link)”

ie
This topic post#1

[This topic post#1](https://meta.discourse.org/t/how-to-remove-website-name-links-shared-in-a-topic-post/257646?u=heliosurge)

You can also do this to the link

[This topic post#1](https://meta.discourse.org/t/
/257646)

If internal you can shortner it to this.

[This topic post#1](/t/
/257646)
2 Likes

Thank you both for your helpful replies. It was hard to mark which is the solution.

@supermathie Shared the logic, root cause of the issue and in a way solve the issue by avoiding using Categories as links.

@Heliosurge Provided the solution to resolve the issue as a whole.

1 Like

Ah! Thought you already were aware since you used this method in your OP:

It will resolve to a more user friendly link that looks like...

 [My Category - My Website Name](https://MyWebsite.com/t/MyCategory)
1 Like

Yeah it can be hard when multiple roots have value.

A theme-component you might like for sharing content externally as links can be quite long. Is Share Link Shortener

1 Like

I think he was looking to strip the link down if not mistaken to bare minimum. My final shortened link is handy as it also prevents an issue if the client changes domain name breaking the links.

Your right. I did know how to use…

In a perfect world, I was hoping for a checkbox to untick
[ ] Exclude Website Name from Internal Category links

This perfect world solution would prevent other users who post https://MyWebsite.com/t/MyCategory (without markdown - [Text](link)) and having it resolve to Category - My Website Name

So although @heilyatsitepoint solution does not solve the issue for other users posting category links without markdown, it will at least solve the issue for when I make posts (since I will always use the markdown).

For the remaining of other users posts…I may just have to turn a blind eye…or edit their post and add the markdown for them. - Yes, I have a little bit of OCD lol.

1 Like

This is kind of what I was wondering… since we exclude the site name from intra-site topic links, we may want to also exclude the site name from intra-site category links.

I should mention there’s another way of doing this that might suit you: feature (#feature) gives you a direct link to the category.

3 Likes

This will be of interest for you and other users

Screenshots_2023-03-09-18-08-16

Share link shortener

Excellent suggestion for both Category link and tags.

Negative. No matter how long or short the URL is, its resolved to a friendly name
MyCategory/Topic - MyWebsiteName

Regarding the shortened link…

I love that feature! I was worried that if someone was to right click and copy the link it would copy /t/ /257646 but it will actually still copy the entire URL which is great for those who right click and share outside of the forum. Win-Win :).

Thanks for the tip!

1 Like

You don’t need that newline; you can do e.g.:

[This Topic](/t/257646)

This Topic

2 Likes

This handy if your also considering a domain change as all links that use site domain in the l8nk will break. A client decided to change from “.ai” to “.com” had to fix some important links manually and any post with images still requored using the wrench to rebuild html o fix image displays in posts.

They should have used the discourse remap script - that’s what we do transparently when we have customers change their hostname.

2 Likes

I agree, I feel its irrelevant to have the site name shown within the same site.
Imagine if every Google Search result included - Google to the end of the title lol.

It is however useful to retain the site name for outside links though.

That’s a very nifty feature (still requires the need to educate others who post on my website, but great for personal use…and those who actually read documentation lol).

I tried that on my website, but it just created a bolded #Category it does not include the nice folder icon. Is that a theme component?

Well that would fall to me to complete. Thanks Now I know for future. What is the exact commandline or was that it? Still learning a lot. lol

1 Like

I’m not sure? Maybe it is?

I’d recommend this guide:

3 Likes

Oh, I switched my domains, but just did a remap function in the console which is basically Find & Replace all URL instances to the new domain to fix broken links.

This was the guide I followed: Change the domain name or rename your Discourse

1 Like

Announcements at times can help with tops and tricks for users. I often do it the harder way before learning a new easier method. lol

1 Like