Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative markdown links between blog and docs does not work #9117

Open
6 of 7 tasks
quinn-p-mchugh opened this issue Jul 1, 2023 · 3 comments
Open
6 of 7 tasks

Relative markdown links between blog and docs does not work #9117

quinn-p-mchugh opened this issue Jul 1, 2023 · 3 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: advanced Issues that are complex, e.g. large scoping for long-term maintainability. domain: markdown Related to Markdown parsing or syntax

Comments

@quinn-p-mchugh
Copy link

quinn-p-mchugh commented Jul 1, 2023

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Hi Docusaurus team,

Love this library - thank you for your awesome work!

I'm looking to link a blog post to a docs page using a relative markdown link, but I receive the following error when I specify [link to doc](../../docs/doc-page.md) in the blog post:

[WARNING] Blog markdown link couldn't be resolved: (../../docs/doc-page.md) in "/home/projects/github-dc5ygn/blog/blog-post.md

On the other hand, using link without the .md ([link to doc](../../docs/doc-page)) extension works fine.

Is there a way I can prevent the broken link while preserving the .md extension? I'm using an Obsidian plugin to convert wikilinks to internal links and need to keep the .md extension for it to work properly.

Reproducible demo

https://stackblitz.com/edit/facebook-docusaurus-mx3fkh?file=blog%2Fblog-post.md

Steps to reproduce

  1. Go to demo linked above.
  2. Wait for the site to compile. You should see a warning: [WARNING] Docs markdown link couldn't be resolved: (../../docs/doc-page.md) in "/home/projects/facebook-docusaurus-mx3fkh/docs/doc-page.md" for version current
  3. In the website preview on the right, click the menu button (three bars).
  4. Click Blog.
  5. Under the "blog-post" title click "link to doc".
  6. You should see a "Page Not Found" error.
  7. Edit "blog-post.md" to exclude ".md" from the link: [link to doc](../../docs/doc-page)
  8. Complete steps 2-5. Link should now work correctly.

Expected behavior

The link [link to doc](../../docs/doc-page) should work regardless of whether or not .md is specified.

Actual behavior

The link [link to doc](../../docs/doc-page) only works when .md is omitted.

Your environment

  • Public source code: See demo link above
  • Public site URL: See demo link above
  • Docusaurus version used: 2.4.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 16.20.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): N/A

Self-service

  • I'd be willing to fix this bug myself.
@quinn-p-mchugh quinn-p-mchugh added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jul 1, 2023
@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Jul 3, 2023
@slorber
Copy link
Collaborator

slorber commented Jul 3, 2023

Yes, it does not work, because currently the relative link resolution is a plugin-specific feature and not a Docusaurus core feature.

I'd like to support cross-plugin relative links but it would require the core engine to somehow maintain a "file path -> URL path" mapping, and we probably need additional plugin lifecycle hooks for that.

Note: if you use Docs versioning, once your docs get versioned, the docs copy will be at a different location and it might break your relative links that are not linking to the same current version (I mean: a relative link from v1.3 to v1.3 won't break, but a v1.3 relative link to a blog post might break when the doc is moved from ./docs to ./versioned_docs/1.3).

@quinn-p-mchugh
Copy link
Author

quinn-p-mchugh commented Jul 3, 2023

Hi @slorber,

Thanks for confirming! I now see this is noted in the documentation here.

Good to know regarding doc versioning. Fortunately, I do not have a need for versioned docs at this time.

Seems like I might be able to workaround this by using regular expressions to remove the .md in the GitHub Obsidian Publisher settings, but we'll see.

Very much appreciate your help.

@Josh-Cena Josh-Cena added difficulty: advanced Issues that are complex, e.g. large scoping for long-term maintainability. domain: markdown Related to Markdown parsing or syntax labels Jul 16, 2023
@ADNANALISALHADABY

This comment was marked as spam.

mnonnenmacher added a commit to oss-review-toolkit/ort that referenced this issue Jan 13, 2024
Integrate the tutorial with the docs to solve the issue that links
between the docs and the tutorial had to be URL links which could not be
resolved when the Markdown files were rendered on GitHub [1].

[1]: facebook/docusaurus#9117

Signed-off-by: Martin Nonnenmacher <[email protected]>
mnonnenmacher added a commit to oss-review-toolkit/ort that referenced this issue Jan 13, 2024
Integrate the tutorial with the docs to solve the issue that links
between the docs and the tutorial had to be URL links which could not be
resolved when the Markdown files were rendered on GitHub [1].

[1]: facebook/docusaurus#9117

Signed-off-by: Martin Nonnenmacher <[email protected]>
mnonnenmacher added a commit to oss-review-toolkit/ort that referenced this issue Jan 14, 2024
Integrate the tutorial with the docs to solve the issue that links
between the docs and the tutorial had to be URL links which could not be
resolved when the Markdown files were rendered on GitHub [1].

[1]: facebook/docusaurus#9117

Signed-off-by: Martin Nonnenmacher <[email protected]>
mnonnenmacher added a commit to oss-review-toolkit/ort that referenced this issue Jan 14, 2024
Integrate the tutorial with the docs to solve the issue that links
between the docs and the tutorial had to be URL links which could not be
resolved when the Markdown files were rendered on GitHub [1].

[1]: facebook/docusaurus#9117

Signed-off-by: Martin Nonnenmacher <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: advanced Issues that are complex, e.g. large scoping for long-term maintainability. domain: markdown Related to Markdown parsing or syntax
Projects
None yet
Development

No branches or pull requests

4 participants