Repository navigation
Relative links are not imported correctly from 2.x #8280
Replies: 1 comment 1 reply
|
The 3.x relative-link rules you quoted match the upgrade guide. Under those rules, a 2.x link written as I could not find a step in the 3.x importer that rewrites the old 2.x forms to the new ones, which is why a large import keeps the broken siblings you described. Improving the importer is a reasonable feature request; I am not a maintainer and cannot say whether that will be added. Until then, you can normalize the 2.x Markdown before import. On each page, rewrite only links that would change meaning:
A conservative preview over an export (adjust the root to your 2.x data directory): python3 - <<'PY'
import re, pathlib
root = pathlib.Path("path/to/2x-export")
pat = re.compile(r'\[([^\]]+)\]\((?!/|./|#|https?:|mailto:)([^)]+)\)')
for p in root.rglob("*.md"):
text = p.read_text(encoding="utf-8")
new = pat.sub(r'[\1](./\2)', text)
if new != text:
print(p)
PYReview the list, then write the files back with the same substitution. Keep a copy of the export. Links that were intentionally "into a child path named xyz" in 2.x should not get the After import, spot-check a few previously broken |
Uh oh!
There was an error while loading. Please reload this page.
As stated in 3.x Upgrade guide, the behavior of relative links changed to make Wiki.JS closer to other platforms. I do agree that the new behavior makes more sense than the previous behavior.
This, however, is causing a big trouble to import data from a 2.x instance because the relative links are not fixed leading to a lot of missing links that are not hard to fix manually but may require to much work for large wikis. Isn't it better to improve the import procedure to fix those links during the page processing?
For example. In the page
p1:[ABC](xyz)[ABC](p1/xyz)[ABC](./xyz)[ABC](xyz)[ABC](/full/path/xyz)[ABC](/full/path/xyz)By the way, thanks for the incredible work!
All reactions