Shortening relative URLS

Our content structure for different API versions is:

├── v1/
│   ├──
│   └── subdir
│         └──
├── v2/
│   ├──
│   └── subdir
│         └──
... v3,v4 ...

Most of the content across versions is the same. to point to content in other directories, Because of the versions, we can’t use relative URLs starting from root, but from depth. we use relative links like, say inside a sub dir.

#from a page 2 levels deep

#from a page4 levels deep

depending on the level the ../ starts increasing & the page is flooded with lots of ../../../../ .

Is there any trick to either set as a new base as a variable per page (or automatically fetched) and do it like this:

base = './././'

or use a directory-level root so that

inside content/v1 base=/v1
inside content/v2 base=/v2

so that relative URLs can be shortened.

Any suggestion on this would be great …