user-content- prefix of user-generated IDs in markup breaks anchored links between files or wiki pages #5638

Closed
opened 2025-11-02 06:31:35 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @AnneLaureF on GitHub (Jun 26, 2020).

Description

Since #9477 the web interface adds a "user-content-" prefix to IDs in markup files.
The internal links [link to internal anchor](#my-anchor) are correctly updated with the prefix, but links to an anchor of another file are not. This makes the link point to a non existing ID and navigation ends up at the top of the other page.

This breaks navigation between long markup files.
Tested with markdown files in repository, and in the wiki pages, as you can see in the test repo https://try.gitea.io/annelauref/TEST_prefix_ID

I think a solution would be to add the prefix to anchors in relative links.

Edited to say: manually adding user-content- to links between file could be a workaround for some repos but it is confusing (needed for some links but no all) and breaks compatibility with at least Github (for me it's happening on a repo that has multiple remotes, one on an internal Gitea server and one on Github)

Screenshots

As you can see in this image, this link is not rewritten:
image

But the anchor in the other file is rewritten:
image

Originally created by @AnneLaureF on GitHub (Jun 26, 2020). - Gitea version (or commit ref): 1.12.1 - Git version: 2.20.1 - Operating system: Debian 10 - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) https://try.gitea.io/annelauref/TEST_prefix_ID - [ ] No - [ ] Not relevant - Log gist: ## Description Since #9477 the web interface adds a "user-content-" prefix to IDs in markup files. The internal links `[link to internal anchor](#my-anchor)` are correctly updated with the prefix, but links to an anchor of another file are not. This makes the link point to a non existing ID and navigation ends up at the top of the other page. This breaks navigation between long markup files. Tested with markdown files in repository, and in the wiki pages, as you can see in the test repo https://try.gitea.io/annelauref/TEST_prefix_ID I think a solution would be to add the prefix to anchors in relative links. Edited to say: manually adding user-content- to links between file could be a workaround for some repos but it is confusing (needed for some links but no all) and breaks compatibility with at least Github (for me it's happening on a repo that has multiple remotes, one on an internal Gitea server and one on Github) ## Screenshots As you can see in this image, this link is not rewritten: ![image](https://user-images.githubusercontent.com/497836/85844862-aee4bd80-b7a3-11ea-9d28-fdf9094a7776.png) But the anchor in the other file is rewritten: ![image](https://user-images.githubusercontent.com/497836/85844955-cde34f80-b7a3-11ea-9d9b-690f7a40e720.png)
GiteaMirror added the topic/ui label 2025-11-02 06:31:35 -06:00
Author
Owner

@lafriks commented on GitHub (Jun 26, 2020):

I think #11903 should fix this

@lafriks commented on GitHub (Jun 26, 2020): I think #11903 should fix this
Author
Owner

@AnneLaureF commented on GitHub (Jun 26, 2020):

Oh great, I tried searching everywhere but obviously didn't use the right keywords. Thank you for pointing me to the right place.
I'll wait patiently for 1.13.0 then :)

@AnneLaureF commented on GitHub (Jun 26, 2020): Oh great, I tried searching everywhere but obviously didn't use the right keywords. Thank you for pointing me to the right place. I'll wait patiently for 1.13.0 then :)
Author
Owner

@silverwind commented on GitHub (Jun 26, 2020):

Yes, #11903 will make anchors from URL work with and without the user-content- prefix. The feature does require JS to be enabled, but that applies to GitHub's links too.

@silverwind commented on GitHub (Jun 26, 2020): Yes, #11903 will make anchors from URL work with and without the `user-content-` prefix. The feature does require JS to be enabled, but that applies to GitHub's links too.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5638