Published topic with a link to itself in the forum?

A published page “has” two links.

A /pub/ that links to the standalone page:

image

A /t/ that links to the topic:

Now, there’s a loop in the topic, as you said.

A way to prevent this would be using this:

For instance, write this in your topic/published page:

[wrap=topic-link]Link to topic: https://discourse.canapin.dev/t/published-page-with-own-topic-link/244[/wrap]

Content 🧑‍💻

In your CSS, write:

article [data-wrap="topic-link"] {
  display: none;
}

Now, here’s what the published page and topics look like:
image

The only issue is that there’s a margin-top on the first visible content in the topic because of this Discourse’s default rule:

.cooked>*:first-child, .d-editor-preview>*:first-child {
    margin-top: 0;
}

The first element, while hidden, still is the first element detected in the CSS. This can be circumvented, of course, but it will depend on how you organize your content. The problem won’t occur if your topic’s link isn’t the first content in the post, for example.

2 Likes