19

I'm using markdown for the README file in my repositories.

Relative links work well for files in the same repo.

But I want to link a file in a submodule (so that the same version as the submodule is displayed).

The usecase is the following: I have a submodule in external/fancy-lib. In the README.md of my repository I want to add "please refer to fancy-lib's [README](external/fancy-lib/README.md) for info about the required packages", but it generates a non-existent link.

Adding a link to fancy-lib's README from fancy-lib's repository would point to HEAD which is not always the same version included in my repository. On the other hand, manually updating the link each time the submodule is updated to a new version (git pull) is a burden of maintenance.

Any workaround?

fferri
  • 18,285
  • 5
  • 46
  • 95
  • You can try doing normal `[link](../external/fancy-lib/README.md)` but I'm not sure it works for submodules. – ahmet alp balkan Jun 02 '17 at 16:19
  • I assumed external directory is one level above for some reason, if it's not, you don't need the `..` at all. Also check: https://stackoverflow.com/questions/7653483/github-relative-link-in-markdown-file?rq=1 – ahmet alp balkan Jun 02 '17 at 22:44

1 Answers1

1

I do not think relative links are going to work. One can always use the full URL though, which is something like

![](https://raw.githubusercontent.com/<account>/<name of submodule repo>/README.md)

or

https://github.com/<account>/<repo>/blob/<hash>/README.md
aless80
  • 3,122
  • 3
  • 34
  • 53
  • 1
    I explicitly mentioned *relative* because I want to avoid this. – fferri Jul 02 '21 at 14:10
  • Btw, since the submodule points to a specific version, the full URL is something like: `https://github.com///blob//README.md` – fferri Jul 02 '21 at 14:12