Linking from one .md file to another #22595
-
I’m working on two different documents for the same project: Overview.md and Getting Started.md. I’m working on them in my local repository, in a new branch just for adding documentation. I want to link from each of them to the other one, but nothing I put into the url part of the link (the second part, in parentheses) seems to work. I’ve tried: [click here for the Getting Started documentation](Getting Started.md) and [click here for the Getting Started documentation](myProjectName/Getting Started.md) What I really want is the URL that will be correct once I finally commit the document to the Master branch of the repo. (BTW, does it matter that I have a space in my document name? It didn’t work when I tried to link to the other document, either, and that document has no space in the name.) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Well, if your goal is that it will work when you finally commit it to the master branch, just put this URL in:
|
Beta Was this translation helpful? Give feedback.
-
Yeah, I guess that’s really all I care about. I was hoping to be able to see it work in the working branch before the commit to Master, but I guess that’s not really all that important. Thanks, @mpboom. |
Beta Was this translation helpful? Give feedback.
-
If they’re in the root of your repo, then you should only need to use the name of the file with nothing else. GitHub rewrites the URLs so that it should work no matter what branch you’re on. See the relative links help documentation for a full explanation. But yes, having spaces in the file name does cause a problem because, according to the Markdown specification, link destinations are not allowed to have spaces in them. You’ll notice that I was able to easily link to the file with no spaces in the name here. But when trying to link back to the file with spaces, it doesn’t work. I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Got it! Thanks for the clarification! |
Beta Was this translation helpful? Give feedback.
-
I found a solution!! You have to replace the spaces with %20 and it worked for me! Here both .md files were in the same folder. Just do something along the lines
Hope this helps :slight_smile: |
Beta Was this translation helpful? Give feedback.
-
Thanks for that! I have since moved all of my docs to the wiki, and it allows you to connect pages to each other (all within the wiki) like this. My other document is called “Getting Started”, and although I feel like it’s probably stored as a separate file, in the wiki system, it’s referred to as a “page”. At any rate… pages / documents within the same wiki can be linked like this: click here for the Getting Started documentation. |
Beta Was this translation helpful? Give feedback.
Well, if your goal is that it will work when you finally commit it to the master branch, just put this URL in: