Markdown 怎么插入图片:本地路径 / 图床 / 相对路径
图片语法其实就一行,难的是“为什么换了电脑就不显示了”。这篇把路径、图床和离线管理一次说清。
Markdown 怎麼插入圖片:本地路徑 / 圖床 / 相對路徑
圖片語法其實就一行,難的是「為什麼換了電腦就不顯示了」。這篇把路徑、圖床和離線管理一次說清。
How to Insert Images in Markdown: Local Paths / Image Hosts / Relative Paths
The image syntax is really just one line—what's hard is "why doesn't it show after I change computers." This article covers paths, image hosts, and offline management in one go.
一、图片语法本身
Markdown 的图片就是“前面带 ! 的链接”,结构是 :

!表示这是图片,不是链接;- 方括号里是“替代文字”,图片加载失败或读屏时会读出来,对无障碍和 SEO 都有帮助;
- 圆括号里是图片地址,可以是网址,也可以是本地文件路径;
- 末尾引号里是鼠标悬停提示,可省略。
记法:把链接的语法记成 [文字](地址),前面加个 ! 就变成图片——文字变成了“替代文字”。
二、相对路径怎么写才稳
把图片和 .md 放在同一文件夹,用相对路径引用,是最适合离线、长期保存的写法:
./images/cat.png # 当前目录下的 images 文件夹
../img/logo.png # 上一级目录的 img 文件夹
相对路径的好处是:整个文件夹打包带走,换电脑、换盘符都不会断链。关键点是路径相对于“当前 Markdown 文件的位置”,而不是相对于你打开预览的网页根目录。
| 写法 | 含义 |
|---|---|
cat.png | 和 md 同目录 |
./cat.png | 同上,显式写当前目录 |
images/cat.png | md 下的 images 子目录 |
../cat.png | 上一级目录 |
三、图床与网络图片
如果你想把文档直接发到网上(博客、公众号、论坛),图片地址用网址最方便:

常见做法:把图片上传到对象存储 / 图床,拿到一个 HTTPS 链接填进去。优点是“一处上传、处处可显”;缺点是链接失效图片就没了,长期文档要选靠谱的服务,并保留本地备份。
四、离线写作如何管图片
纯本地写作时,推荐这样的目录结构,路径清晰又好迁移:
我的文档/
├─ 笔记.md
└─ 笔记.assets/
├─ cat.png
└─ diagram.svg
在 笔记.md 里写 。很多笔记软件(Obsidian、Typora)会自动采用这种“同名 .assets 文件夹”约定,拖图进文档就自动归位。
五、图片不显示的 5 个原因
1. 路径拼错或大小写不一致
Linux / 部署到服务器的环境区分大小写,Cat.png 和 cat.png 不是同一个文件。
2. 相对路径基准不对
预览器按“md 文件位置”解析相对路径;如果你用网页根目录去想,就会差一层。
3. 图床链接失效或被防盗链
部分图床禁止跨站引用,浏览器会拦截,换成允许外链的服务或自托管即可。
4. 少了 !
写成 [文字](图) 只会渲染成链接,不是图片——这是最常见的手滑。
5. 中文/空格路径未处理
路径含空格或中文时,给地址套上 %20 或用引号包裹更稳妥。
六、常见问题
Q:能不能调图片大小?
A:标准 Markdown 不支持尺寸参数。需要的话可用 HTML 的 <img src="..." width="300">,多数预览器都能渲染。
Q:基地址(base URL)能统一设置吗?
A:部分静态网站生成器支持配置 image_base_url,让相对路径自动拼上域名;纯手写 md 则直接写全网址最省事。
Q:在 365Lab 编辑器里怎么插图?
A:编辑器内容保存在本地,你可在支持 HTML 的场景用 <img>,或先把图片传到图床再用网址引用;需要批量管图时,本地相对路径 + 归档文件夹最稳。
图片之外,最常用的是表格和导出:看 Markdown 表格怎么写,或 怎么把 Markdown 转 PDF。
一、圖片語法本身
Markdown 的圖片就是「前面帶 ! 的連結」,結構是 :

!表示這是圖片,不是連結;- 方括號裡是「替代文字」,圖片載入失敗或讀屏時會讀出來,對無障礙和 SEO 都有幫助;
- 圓括號裡是圖片位址,可以是網址,也可以是本地檔案路徑;
- 末尾引號裡是滑鼠懸停提示,可省略。
記法:把連結的語法記成 [文字](位址),前面加個 ! 就變成圖片——文字變成了「替代文字」。
二、相對路徑怎麼寫才穩
把圖片和 .md 放在同一資料夾,用相對路徑引用,是最適合離線、長期保存的寫法:
./images/cat.png # 目前目錄下的 images 資料夾
../img/logo.png # 上一層目錄的 img 資料夾
相對路徑的好處是:整個資料夾打包帶走,換電腦、換碟符都不會斷鏈。關鍵點是路徑相對於「目前 Markdown 檔案的位置」,而不是相對於你打開預覽的網頁根目錄。
| 寫法 | 含義 |
|---|---|
cat.png | 和 md 同目錄 |
./cat.png | 同上,顯式寫目前目錄 |
images/cat.png | md 下的 images 子目錄 |
../cat.png | 上一層目錄 |
三、圖床與網路圖片
如果你想把文件直接發到網上(部落格、公眾號、論壇),圖片位址用網址最方便:

常見做法:把圖片上傳到物件儲存 / 圖床,拿到一個 HTTPS 連結填進去。優點是「一處上傳、處處可顯」;缺點是連結失效圖片就沒了,長期文件要選靠譜的服務,並保留本地備份。
四、離線寫作如何管圖片
純本地寫作時,推薦這樣的目錄結構,路徑清晰又好遷移:
我的文件/
├─ 筆記.md
└─ 筆記.assets/
├─ cat.png
└─ diagram.svg
在 筆記.md 裡寫 。很多筆記軟體(Obsidian、Typora)會自動採用這種「同名 .assets 資料夾」約定,拖圖進文件就自動歸位。
五、圖片不顯示的 5 個原因
1. 路徑拼錯或大小寫不一致
Linux / 部署到伺服器的環境區分大小寫,Cat.png 和 cat.png 不是同一個檔案。
2. 相對路徑基準不對
預覽器按「md 檔案位置」解析相對路徑;如果你用網頁根目錄去想,就會差一層。
3. 圖床連結失效或被防盜鏈
部分圖床禁止跨站引用,瀏覽器會攔截,換成允許外連的服務或自託管即可。
4. 少了 !
寫成 [文字](圖) 只會渲染成連結,不是圖片——這是最常見的手滑。
5. 中文/空格路徑未處理
路徑含空格或中文時,給位址套上 %20 或用引號包裹更穩妥。
六、常見問題
Q:能不能調圖片大小?
A:標準 Markdown 不支援尺寸參數。需要的話可用 HTML 的 <img src="..." width="300">,多數預覽器都能渲染。
Q:基地址(base URL)能統一設定嗎?
A:部分靜態網站產生器支援設定 image_base_url,讓相對路徑自動拼上網域;純手寫 md 則直接寫完整網址最省事。
Q:在 365Lab 編輯器裡怎麼插圖?
A:編輯器內容儲存在本機,你可在支援 HTML 的場景用 <img>,或先把圖片傳到圖床再用網址引用;需要批量管圖時,本地相對路徑 + 歸檔資料夾最穩。
圖片之外,最常用的是表格和匯出:看 Markdown 表格怎麼寫,或 怎麼把 Markdown 轉 PDF。
1. The image syntax itself
A Markdown image is just "a link with a ! in front." Its structure is :

!means this is an image, not a link;- The square brackets hold the "alt text," read out when the image fails to load or by a screen reader—helping both accessibility and SEO;
- The parentheses hold the image address, which can be a URL or a local file path;
- The trailing quoted text is a hover tooltip and can be omitted.
Memory aid: Remember the link syntax as [text](URL); put a ! in front and it becomes an image—the text becomes the "alt text."
2. Writing stable relative paths
Keeping images in the same folder as the .md and referencing them by relative path is the best approach for offline use and long-term storage:
./images/cat.png # the images folder under the current directory
../img/logo.png # the img folder one level up
The benefit of relative paths: bundle the whole folder and take it with you—no broken links when you switch computers or drives. The key point is thatthe path is relative to "the location of the current Markdown file," not to the web root you opened the preview from.
| Form | Meaning |
|---|---|
cat.png | same folder as the md |
./cat.png | same as above, explicitly the current directory |
images/cat.png | the images subfolder under md |
../cat.png | one level up |
3. Image hosts and web images
If you want to publish the document straight to the web (blog, WeChat, forum), an image URL is the most convenient:

The common approach: upload the image to object storage / an image host and drop in the HTTPS link you get. The upside is "upload once, show anywhere"; the downside is thatif the link dies, the image is gone, so for long-lived docs pick a reliable service and keep a local backup.
4. Managing images for offline writing
For purely local writing, this directory structure keeps paths clear and easy to migrate:
MyDocs/
├─ note.md
└─ note.assets/
├─ cat.png
└─ diagram.svg
In note.md write . Many note apps (Obsidian, Typora) adopt this "same-name .assets folder" convention automatically—drag an image into the doc and it's filed for you.
5. 5 reasons images don't show
1. A mistyped path or mismatched case
Linux and server environments are case-sensitive: Cat.png and cat.png are not the same file.
2. Wrong relative-path base
Previewers resolve relative paths from "the md file's location"; if you think in terms of the web root, you'll be off by a level.
3. Dead image-host link or hotlink protection
Some hosts forbid cross-site references and the browser blocks them; switch to a service that allows external linking or self-host.
4. Missing !
Writing [text](image) renders only a link, not an image—the most common slip of the finger.
5. Unhandled Chinese characters / spaces in the path
When the path contains spaces or Chinese characters, wrapping the address in %20 or quotes is safer.
6. FAQ
Q: Can I resize an image?
A: Standard Markdown doesn't support size parameters. If you need them, use an HTML <img src="..." width="300">; most previewers render it fine.
Q: Can I set a base URL uniformly?
A: Some static site generators let you configure image_base_url so relative paths automatically get the domain prepended; for hand-written md, just writing the full URL is simplest.
Q: How do I insert images in the 365Lab editor?
A: The editor stores content locally; where HTML is supported you can use an <img> tag, or upload the image to a host first and reference it by URL. For bulk image management, a local relative path plus an archive folder is safest.
Beyond images, the most common needs are tables and export: see How to write Markdown tables, or How to turn Markdown into PDF.