Codeberg/Community
54
324
Fork
You've already forked Community
12

Relative HTML links in Readme files aren't working? #2270

Open
opened 2025年12月23日 23:59:06 +01:00 by markseuffert · 3 comments

Comment

Hello,

I migrated a repository from GitHub to Codeberg and found a small compatibility problem. On Codeberg the link normalisation in Readme files works differently depending on your current location. I checked existing issues and found out that relative links can be improved with a prefix, using ./README-de.md instead of README-de.md, unfortunately this only helps under certain conditions.

Here's an example which doesn't work on our repository's start page:

<p align="right"><a href="README-de.md">Deutsch</a> &nbsp; <a href="README.md">English</a> &nbsp; <a href="README-sv.md">Svenska</a></p>

The first link points to https://codeberg.org/datenstrom/README-de.md
instead of pointing to https://codeberg.org/datenstrom/yellow/src/branch/main/README-de.md.

A prefix like ./ helps if you use Markdown links, but unfortunately not if you use HTML <a> elements.

First impression, everything works well. We were a bit puzzled as to why our language switcher only worked on subpages and not on the repository's start page. We tried various Markdown workarounds and suspected that absolute URLs are required on Codeberg. That would fix the problem, but also make forking harder. By the way, for images it makes apparently no difference at all, we can use the same HTML format on Codeberg and GitHub.

Please let me know if this is the expected behaviour. I would be grateful for any comments or suggestions.

### Comment Hello, I migrated a repository from GitHub to Codeberg and found a small compatibility problem. On Codeberg the link normalisation in Readme files works differently depending on your current location. I checked existing issues and found out that relative links can be improved with a prefix, using `./README-de.md` instead of `README-de.md`, unfortunately this only helps under certain conditions. Here's an example which doesn't work on our repository's start page: ``` html <p align="right"><a href="README-de.md">Deutsch</a> &nbsp; <a href="README.md">English</a> &nbsp; <a href="README-sv.md">Svenska</a></p> ``` The first link points to `https://codeberg.org/datenstrom/README-de.md` instead of pointing to `https://codeberg.org/datenstrom/yellow/src/branch/main/README-de.md`. A prefix like `./` helps if you use Markdown links, but unfortunately not if you use HTML `<a>` elements. First impression, everything works well. We were a bit puzzled as to why our language switcher only worked on subpages and not on the repository's start page. We tried various Markdown workarounds and suspected that absolute URLs are required on Codeberg. That would fix the problem, but also make forking harder. By the way, for images it makes apparently no difference at all, we can use the same HTML format on Codeberg and GitHub. Please let me know if this is the expected behaviour. I would be grateful for any comments or suggestions.

Hi, please check forgejo/forgejo#6360

Hi, please check https://codeberg.org/forgejo/forgejo/issues/6360
markseuffert changed title from (削除) Relative links in Readme files aren't working? (削除ここまで) to Relative HTML links in Readme files aren't working? 2025年12月28日 19:54:28 +01:00

Thank you for the link, there was a similar issue in #252. Maybe this is about a different problem, I am using relative links that do not start with a slash. When testing documentation four days ago, I found out that some links are rendered/transformed differently, not only on the repository's start page, but also if you use Markdown or HTML format for links. To be fair, I should mention my colleague Steffen, who also tested for several hours and we expected that this problem would not be easy to pin down. Today I did another test. If I am not mistaken then the behaviour on Codeberg has changed since last time. There is no longer a problem with relative Markdown links, what remains is a problem with relative HTML links.

Here's a reduced test case. You need a README.md and README-de.md, both files could have the same content:

# Yellow test
Documentation test on Codeberg for language switcher.
## Markdown
Test 1 [Deutsch](README-de.md) - [English](README.md)
## HTML
Test 2 <a href="README-de.md">Deutsch</a> - <a href="README.md">English</a>

Results:

  • Test 1 with the relative Markdown links works fine.
  • Test 2 with the relative HTML links does not work as expected.
  • On the repository's start page, the links in test 2 point to the wrong URL and browser shows a 404.
  • On a sub page, for example if you navigate to a Readme file first, all links point to the correct URL.
Thank you for the link, there was a similar issue in #252. Maybe this is about a different problem, I am using relative links that do not start with a slash. When testing documentation four days ago, I found out that some links are rendered/transformed differently, not only on the repository's start page, but also if you use Markdown or HTML format for links. To be fair, I should mention my colleague Steffen, who also tested for several hours and we expected that this problem would not be easy to pin down. Today I did another test. If I am not mistaken then the behaviour on Codeberg has changed since last time. There is no longer a problem with relative Markdown links, what remains is a problem with relative HTML links. Here's a reduced test case. You need a `README.md` and `README-de.md`, both files could have the same content: ``` # Yellow test Documentation test on Codeberg for language switcher. ## Markdown Test 1 [Deutsch](README-de.md) - [English](README.md) ## HTML Test 2 <a href="README-de.md">Deutsch</a> - <a href="README.md">English</a> ``` Results: - Test 1 with the relative Markdown links works fine. - Test 2 with the relative HTML links does not work as expected. - On the repository's start page, the links in test 2 point to the wrong URL and browser shows a 404. - On a sub page, for example if you navigate to a Readme file first, all links point to the correct URL.

I think the wiki has the same problem as the Readme files. Which makes sense, I suspect they use the same Markdown renderer for the content. Here's how to reproduce the problem. Create a wiki Home with the content below, you also need to create two wiki pages,deutsch and english with any content.

# Yellow test
Wiki test on Codeberg for relative links.
## Markdown
Test 1 [Deutsch](deutsch) - [English](english)
## HTML
Test 2 <a href="deutsch">Deutsch</a> - <a href="english">English</a>

Results:

  • Test 1 with the relative Markdown links works fine.
  • Test 2 with the relative HTML links does not work as expected.
  • On the wiki home page, the links in test 2 point to the wrong URL and browser shows a 404.

I am not sure if this the expected behaviour or a bug. Any thoughts?

I think the wiki has the same problem as the Readme files. Which makes sense, I suspect they use the same Markdown renderer for the content. Here's how to reproduce the problem. Create a wiki `Home` with the content below, you also need to create two wiki pages,`deutsch` and `english` with any content. ``` # Yellow test Wiki test on Codeberg for relative links. ## Markdown Test 1 [Deutsch](deutsch) - [English](english) ## HTML Test 2 <a href="deutsch">Deutsch</a> - <a href="english">English</a> ``` Results: * Test 1 with the relative Markdown links works fine. * Test 2 with the relative HTML links does not work as expected. * On the wiki home page, the links in test 2 point to the wrong URL and browser shows a 404. I am not sure if this the expected behaviour or a bug. Any thoughts?
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
accessibility

Reduces accessibility and is thus a "bug" for certain user groups on Codeberg.
bug

Something is not working the way it should. Does not concern outages.
bug
infrastructure

Errors evidently caused by infrastructure malfunctions or outages
Codeberg

This issue involves Codeberg's downstream modifications and settings and/or Codeberg's structures.
contributions welcome

Please join the discussion and consider contributing a PR!
docs

No bug, but an improvement to the docs or UI description will help
duplicate

This issue or pull request already exists
enhancement

New feature
infrastructure

Involves changes to the server setups, use `bug/infrastructure` for infrastructure-related user errors.
legal

An issue directly involving legal compliance
licence / ToS

involving questions about the ToS, especially licencing compliance
please chill
we are volunteers

Please consider editing your posts and remember that there is a human on the other side. We get that you are frustrated, but it's harder for us to help you this way.
public relations

Things related to Codeberg's external communication
question

More information is needed
question
user support

This issue contains a clearly stated problem. However, it is not clear whether we have to fix anything on Codeberg's end, but we're helping them fix it and/or find the cause.
s/Forgejo

Related to Forgejo. Please also check Forgejo's issue tracker.
s/Forgejo/migration

Migration related issues in Forgejo
s/Pages

Issues related to the Codeberg Pages feature
s/Weblate

Issue is related to the Weblate instance at https://translate.codeberg.org
s/Woodpecker

Woodpecker CI related issue
security

involves improvements to the sites security
service

Add a new service to the Codeberg ecosystem (instead of implementing into Gitea)
upstream

An open issue or pull request to an upstream repository to fix this issue (partially or completely) exists (i.e. Gitea, Forgejo, etc.)
wontfix

Codeberg's current set of contributors are not planning to spend time on delegating this issue.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/Community#2270
Reference in a new issue
Codeberg/Community
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?