mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-22 06:24:14 -05:00
Relative links not working in asciidoc render #11357
Closed
opened 2025-11-02 09:35:12 -06:00 by GiteaMirror
·
30 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v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1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/bug
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#11357
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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?
Originally created by @deparcus on GitHub (Jul 28, 2023).
Description
I activated asciidoc file render based on https://docs.gitea.com/next/administration/external-renderers:
apt install asciidoctorapp.iniThen I created a branch in one of my repositories and migrated Markdown files to adoc files.
In the main
*.adocfile I use relative links to link to other*.adocfiles.Therefore I followed the asciidoctor documentation.
Example file
docs/README.adoc:I also tried other relative links:
In VSCode the links are working and I can navigate to the files in subdirectories by clicking the link in the main file.
The link is interpreted as it starts from the root of the branch. So
/docs/is missing. But as theREADME.adocis in the folderdocs, the links should be interpreted as starting from there.This is shown in the screenshot below:

I discovered that issue also in another repository, where I first tried it.
When I use Markdown (currently my master branch), everything works as is should.
Example file
doc/README.md:Working links, see screenshot:

Am I doing something wrong?
Or is there maybe an issue with
asciidoctoror theasciidoctorcommand inapp.ini?Would be great if anybody could help me.
Gitea Version
1.20.1
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
Git Version
2.30.2
Operating System
Raspbian/Debian 11.7
How are you running Gitea?
Local install with binary and systemd service.
Database
MySQL
@deparcus commented on GitHub (Jul 28, 2023):
Currently I found another strange thing:
It is not working as described above when clicking the
/docs/folder in the file list and starting from there.But when I go to the
README.adocfile in the/docs/folder via a link in my mainREADME.mdfile in the root of the repository/branch it is working.Link to
README.adocinREADME.md:Now (for some reason) relative links in
README.adocare working as they should:So at the end I'm not sure if this is really a asciidoc render issue or a general behavior of
gitea.But if I just use Markdown (also in my
docfolder), everything works as it should no matter how theREADME.mdfile in thedocfolder is accessed.@Mo-Gul commented on GitHub (Aug 19, 2023):
I have exactly the same issue on two different Gitea's.
tl;dr of the above is
docs/README.adocis active/selected (the address bar shows<repository>/src/branch/main/docs/README.adoc), the link destination works as expected, i.e. are<repository>/src/branch/main/docs/<link_dest>.docsfolder is selected (the address bar shows<repository>/src/branch/main/docs), the link destination is<repository>/src/branch/main/<link_dest>.<repository>), the link destination is<repository>/<link_dest>.With
<repository>for this repository would behttps://github.com/go-gitea/gitea,<link_dest>would be e.g.link.adoc, andlink:<link_dest>.adoc[link destination]in thedocs/README.adocfile.@Mo-Gul commented on GitHub (Aug 19, 2023):
Because GitHub must have had the same issue (I guess), I found github/markup#1039 which might be a good start so find out, how it was solved there.
Hopefully then also
xrefs can be handled or -- depending onsafe-mode--includedirectives are converted automatically to links (as can be seen e.g. at https://github.com/opendevise/asciidoc-samples/blob/main/runtime.adoc)Maybe @mojavelinux could as least give a hint on how to solve the issue here (as well) ...
@mojavelinux commented on GitHub (Aug 19, 2023):
Please don't @ me in projects I'm not involved with. You are welcome to ask in the Asciidoctor project chat at https://chat.asciidoctor.org.
@Mo-Gul commented on GitHub (Aug 25, 2023):
@deparcus, do you want to ask for help in the asciidoctor chat since you started the issue? If not, please let me know and I'll try to do it myself.
@deparcus commented on GitHub (Aug 25, 2023):
@Mo-Gul : Of course I could try, but I think you might be able to explain the details and background probably much better than I could.
@Mo-Gul commented on GitHub (Aug 25, 2023):
@deparcus, I'd say you give it a first try and can give a hint to this issue, which I guess is a good start. Then you can add the link to the chat here so I (and others) can follow the conversation. If it is useful that I add my few cents I'll join it ...
@deparcus commented on GitHub (Aug 25, 2023):
@Mo-Gul : I opened the chat at asciidoctor. You can follow and comment there by this link.
@deparcus commented on GitHub (Aug 29, 2023):
@Mo-Gul : There seems to be a solution in the asciidoctor chat.
Looks like
giteahas to change sth.How can we proceed here?
@jtiee commented on GitHub (Sep 1, 2023):
The bug is that Gitea does not add a trailing slash in links to repos/folders.
Consider this situation:
The user views
https://<gitea-host>/<user>/<repository>. Gitea automatically renders theREADMEfile (README.adocin this case, but any format would suffer the same problem).Relative links in the auto-rendered
READMEmight look likedocs/index.adoc. When you click such a link, the browser combines the current URL context with the relative link. The combination uses the existing "folder" (path segment) in the current URL as the context.What "folder" is that?
https://<gitea-host>/<user>because there is no trailing slash after<repository>. So, the browser then attempts to fetchhttps://<gitea-host>/<user>/docs/index.adoc, which results in a 404.If Gitea adds the trailing slash to repo/folder links, then when the user clicks the
docs/index.adoclink, the browser would fetchhttps://<gitea-host>/<user>/<repository>/docs/index.adoc, which is correct.You can manually add a trailing slash (and reload the page) to any repo/folder view and click a relative link in an auto-generated
READMEfile to confirm the correct behavior.I used
gitea-1.20.3-darwin-10.12-amd64for testing.@Mo-Gul commented on GitHub (Sep 1, 2023):
Seems you are right and the "same" problem exists for markdown files as well. See #18592.
@deparcus commented on GitHub (Sep 4, 2023):
hmm... as I wrote in my first to posts, I cannot reproduce the behaviour when using
*.mdMarkdown files.@Mo-Gul commented on GitHub (Sep 7, 2023):
I can confirm that with Gitea v1.19.0 a from a README.md in the docs folder work to another MD file in the docs folder works regardless of how the README.md is shown.
Unfortunately, I couldn't find out why so far. But maybe this has something to do with the Slugify rules for Gitea.
@deparcus, could you setup some dummy Gitea servers with previous versions so we could drill down since when the links are working? Maybe then it is easier to find out exactly why/how this is working for markdown files and thus there hopefully is a good start for a asciidoctor solution.
@deparcus commented on GitHub (Sep 8, 2023):
@Mo-Gul : sure. Do you have a feeling from which version I should start? Then I would start updating version by version and try to find out when the discussed Markdown links are working.
@Mo-Gul commented on GitHub (Sep 9, 2023):
Not really, but I guess I would start with v1.11 and then do a "binary search" when it isn't working there up to <v1.19 where it is working. Maybe it also a good idea to start with v1.16.1 which release date is before the above mentioned bug report from me.
Good luck!!
@deparcus commented on GitHub (Sep 10, 2023):
ok, thanks. I'll start with
v1.11.0untilv1.19.xand do the first probe for the binary search atv1.16.1.Currently I have limited access to the internet (and cannot download large files) due to a few days off. So I can start checking the issues earliest at end of september / beginning of october.
If this is too late, then probably somebody else could jump in?
Otherwise I'll let you all know when I have the first results.
@deparcus commented on GitHub (Oct 13, 2023):
@Mo-Gul : Sorry for answering that late.
I now set up a gitea 1.11.0 instance based on docker-compose to test the relative md-links.
To me it seems that it's working in that version, but I want to doublecheck if I'm testing the right things, before I continue playing around with the version (what is really easy with docker).
Attached you find a zip-file of my testing repo: relative-md-links-master.zip
Here's my
docker-compose.yml:Setup instructions:
apt install docker-composeto install everything you needdocker-compose up(when you want to see the log output) ordocker-compose up -d(if you want to send it to the background) as root in the folder wheredocker-compose.ymlis located to start the containersdbas the hostname androot/giteaas username/password for mysql DB configuration) and then you're ready to go.CRTL+Cif running in the foreground and withdocker-compose downif running in the background.docker system prune -a(deletes everything) anddocker volume rm <volume_name>(list volumes withdocker volume ls). Important: these instructions asumes that you're running no other docker containers and completely cleans up your system, so be careful.It would be nice if you can confirm:
Thanks a lot :)
@Mo-Gul commented on GitHub (Oct 14, 2023):
I don't have much of a clue about docker, so I trust whatever you are doing. But maybe a bit simpler test is
markdown_test-main.zip where there is only one
README.mdin thedocsfolder and the link should work when you are in the base repository directory.Good luck finding the Gitea version where the link isn't working (properly) any more!!
@deparcus commented on GitHub (Oct 19, 2023):
I did some more testing, but still got no real result.
First, I found out that binary testing works not that good when descreasing versions. So everytime the database had to be cleared and initial setup and repo creation has to be done.
So I first tested:
Then I decided just to go versions up and test every .0 version.
What I did:
README.mdfrom the repo rootREADME.mdindocsfolder*.md-file is shownResult:
So to be honest I do not know how to proceed here. Probably I'm testing something wrong (that's why I asked for a doublecheck ;-) ).
I think it might be more efficient to search in the code for the hint how to handle asciidoc links similar to md links.
Sorry for not getting a better result here.
But btw: I was really interesting how gitea look, features and console log output changed from the beginning to the latest version :-) Due to docker the test with version switch (when going up) can be done really quickly.
@Mo-Gul commented on GitHub (Oct 22, 2023):
Since I currently can't setup (easily) other Gitea's myself and I trust your results, I agree that this maybe is a dead end.
I also already tried to find the related code parts where links are handled but I most likely I didn't succeed because I don't know anything about the (programming) language.
So hopefully you have more luck than I do ...
@deparcus commented on GitHub (Oct 27, 2023):
Sorry, me neither, because I also don't know the programming language.
Any other way to proceed here? Probably someone with the right skills should have a look.
@Mo-Gul commented on GitHub (Oct 27, 2023):
That is the obvious way, but I have not much hope here, because up to now nobody else than jtiee commented here. I'd be happy to proven wrong.
Unfortunately the same seems to be true for the asciidoctor chat ... 😢
@deparcus commented on GitHub (Nov 1, 2023):
Sorry @jtiee , I did not see, that you were the one writing in AsciiDoctor Chat.
Are you sure, that it's really a gitea bug? I'm asking because on my side links in Markdown file are working fine and links in AsciiDoc files not. So why should gitea add the trailing slashes in Markdown but not in AsciiDoc e.g.?
Can you help here?
@jtiee commented on GitHub (Nov 2, 2023):
I've updated my PoC so that I have AsciiDoc and Markdown files with the same content:
I used
docs/READ.mdinstead ofdocs/README.mdto avoid auto-rendering the Markdown file.Then I compared the links rendered by Gitea in
docs/index.adocanddocs/index.md. First, here is the markup for the links:docs/index.adoc:docs/index.md:As you can see, both implement relative links. When Gitea renders these:
docs/index.adoc:docs/index.md:As you can see, the rendered Asciidoc files have the relative links as defined in the file. Whereas the Markdown files have an absolute link from the document root. That's the problem.
I don't know if Gitea is making the rendered Markdown links absolute or whether the Markdown renderer used by Gitea is doing that. But nothing is making the AsciiDoc links absolute.
Either Gitea needs to add slashes after folder names, or it needs to make relative links absolute in rendered AsciiDoc files. Adding the slashes after folder names would avoid this issue for any other auto-rendered files. And there's no reason both solutions couldn't be applied.
@lunny commented on GitHub (Nov 3, 2023):
There are two envs to help with your asciidoc command.
GITEA_PREFIX_SRCandGITEA_PREFIX_RAWcould help you to make the links absolute.About how to use, please see https://docs.gitea.com/next/administration/config-cheat-sheet?_highlight=gitea_prefix_src#markup-markup
@Mo-Gul commented on GitHub (Dec 5, 2023):
@lunny, I have stumbled over these variables at different places so far, e.g. also at https://github.com/go-gitea/gitea/issues/6359#issuecomment-1059958752, but unfortunately I couldn't find out how exactly to use these (with a concrete example).
I just gave it some tries with
but unfortunately none of them worked. What am I doing wrong it these environment variables (really) should be able to solve the problem?
@deparcus commented on GitHub (Dec 16, 2024):
Hi,
I just want to ask if there are any news regarding this topic @Mo-Gul / @lunny ?
I'm still really missing the full working AsciiDoc support in Gitea and it seems like there is still no working workaround.
@lunny commented on GitHub (Dec 16, 2024):
Since recently, markup render system has many refactors, I need to confirm whether this issue have been fixed.
@deparcus commented on GitHub (Jan 10, 2025):
@lunny : I updated my gitea to version 1.22.6 and 1.23.1. Still the same behavior :(
Would you please catch up @Mo-Gul s question from 2023-12-05 and help solving the problem?
@wxiaoguang commented on GitHub (Oct 24, 2025):
New Gitea should have fixed various relative path problems. The real fix is https://github.com/go-gitea/gitea/issues/34114 (in 1.24)
Some related details:
GITEA_PREFIX_SRCPlease try Gitea 1.24 stable or 1.25 nightly, feel free to reopen if there is still any problem