How To Have a Link With Spaces in Markdown
I recently edited some Markdown files that needed to link to documents with spaces in their name. I had never done that before and set out to discover how to make it happen. Here’s what I learned.
You can have a markdown link with spaces by wrapping the URL in angle brackets (<>
).
[link](<Your Link With Spaces Here>)
This solution should work on most all flavors of Markdown, as it’s defined in the Common Mark standard that’s used by Discourse, GitHub, GitLab, Reddit, Qt, Stack Overflow, Stack Exchange, and Swift. Here are some examples.
[Some Caption](<https://www.google.com/search?q=how to have spaces in markdown link>)
[Krabby Patty Formula](<./Secret Files/Krabby Patty Formula.md>)
![StLouisArchImage](<./St Louis Arch.jpg>)
Now that you know how to link to items with spaces in Markdown, try to avoid doing so. You’re best off just not having spaces in the name of a file, folder, or URL. Don’t take my word for it though, the engineering community is in agreement on this one. You can use dashes, underscores, or casing styles, just do whatever you can to avoid spaces in names.
But sometimes, it’s out of your control. In that case, do what you got to do, much like a wise man once did a long time ago in a galaxy far far away.
Comments