蘇格拉底式的反問沒有幫助
Published:Updated:
單看我在論壇上的回應表面上看起來會是我莫名其妙不回應問題,但是看完前因後果我想讀者對是非對錯會更加清楚。為避免不必要的搜尋引擎曝光,本文設定為 noindex,因此搜尋 Hugo 相關內容不可能看到本文,這代表這篇文章是原本就是本部落格的讀者才會看到。
以下直接附上原文沒有節錄摘要,我節錄內容可能受到斷章取義的指控,不想看原文的可以自行跳過,內容是複製貼上叫 AI 整理成整齊的格式的,序數有點不同但是文字應該相同。
原文
---
# Hugo Forum Thread
**Title:** What is the officially recommended syntax for relative links?
**Category:** support / markdown
**Views:** 81
**Links:** 4
**Date:** Jan 22
---
## 原始發文(Root Post)
### 發文者:ZhenShuo2021
**時間:2 days ago**
**內容(原文):**
Hi,
I’m trying to understand the correct way to write relative links in markdown. To investigate this, I created a custom render-link.html:
```go
{{- $u := urls.Parse .Destination -}}
{{- with .PageInner.GetPage (strings.TrimPrefix "./" $u.Path) }}
Success: {{ .LinkTitle }}
{{- else }}
Failed to get page: {{ $u.Path }}
{{- end }}
```
with directory structure:
```text
❯ tree content/posts
content/posts
├── _index.md
├── post-3
│ ├── bryce-canyon.jpg
│ └── index.md
└── post-4
└── index.md
```
From post-3/index.md, I tested these different relative link syntaxes:
1. `[a](../post-4)` -> Failed
2. `[b](../post-4/)` -> Failed
3. `[c](../post-4/index.md)` -> Success
4. `[d](./post-4)` -> Success
5. `[e](./post-4/index.md)` -> Success
6. `[f](post-4)` -> Success
In my understanding, a, b, c, and f should work, while d and e should fail because they point to posts/post-3/post-4.
It would be great if the behavior could match VSCode’s path auto-completion logic (a, b, c).
So what is the officially recommended syntax for writing relative links between pages?
Thank you!
---
## 回覆 1
### 發文者:jmooring
**時間:1 day ago**
**內容(原文):**
I would use site-relative link destinations instead of page-relative destinations:
* Page-relative destinations can be difficult to reason about
* Site-relative destinations from Page A to Page B won’t break if you move Page A
Having said that, with a well-formed render hook that uses PageInner.GetPage to resolve link destinations, I would use logical paths, not file paths. What’s the difference?
```
source (file paths)
source (logical paths)
source destination page-relative URL
file path s1/p1/index.md s1/p2.md ../p2.md
logical path s1/p1 s1/p2 p2
file path s1/p1/index.md s2/p3/index.md ../../s2/p3/index.md
logical path s1/p1 s2/p3 ../s2/p3
```
More examples here:
[https://gohugo.io/methods/page/getpage/](https://gohugo.io/methods/page/getpage/)
---
## 回覆 2
### 發文者:jmooring
**時間:1 day ago**
**內容(原文):**
This example site might be helpful, providing examples of:
* Page-relative link destinations using file paths (compatible with VS Code’s path completion feature)
* Page-relative link destinations using logical paths
* Site-relative link destinations using logical paths (my preference)
```
git clone --single-branch -b hugo-forum-topic-56603 https://github.com/jmooring/hugo-testing hugo-forum-topic-56603
cd hugo-forum-topic-56603
hugo server
```
The link render hook is identical to Hugo’s embedded link render hook, except that it throws an error if unable to resolve the link destination to a page, a page resource, or a global resource.
---
## 回覆 3
### 發文者:ZhenShuo2021
**時間:1 day ago**
**內容(原文):**
Thanks for looking into this. I agree that page-relative syntax is not intuitive.
For cross-section links, I believe most users would prefer site-relative links because they are easier to read. That said, my question can be simplified to adjacent linking, specifically parent/child/sibling links.
Regarding the example site, it took me some time to understand the results, and I noticed several noteworthy behaviors:
Self-linking:
The `[p1](./index.md)` link in `s1/p1/index.md` resolves to `/s1` instead of `/s1/p1`.
Syntaxes that include file names (*.md) behave as follows:
* With no changes (commit 3ef7ffd4), everything works as expected.
* After removing render-link.html, it still works.
* After further removing the markup settings, the links break and resolve to the raw *.md files.
At this point, the site is complete using only the default settings, no markup or render hooks are used. Continuing from step 2–3, I tested additional cases beyond the *.md syntaxes:
* Cross-section links and page-relative links also break.
* After adding `slug: p1-slug` to `p1/index.md`, links in `s1/p2` fails to resolve `/s1/p1-slug`.
* After restoring hugo.toml and render-link.html, `/s1/p1-slug` resolves successfully.
Tested using:
```
rm -rf public && hugo server --disableFastRender --ignoreCache
```
each run with:
```
hugo v0.154.5-a6f99cca223a29cad1d4cdaa6a1a90508ac1da71+extended
darwin/arm64
BuildDate=2026-01-11T20:53:23Z
VendorInfo=gohugoio
```
---
## 回覆 4
### 發文者:jmooring
**時間:1 day ago**
**內容(原文):**
I fixed the self-referential link, which was only present for symmetry.
Do you have any other questions?
Test results without the render hook in place (either mine or the embedded version) are irrelevant.
---
## 回覆 5
### 發文者:ZhenShuo2021
**時間:1 day ago**
**內容(原文):**
Removing this means using the embedded render hook, and I expect the same syntax to work whether useEmbedded is set or the almost identical custom render hook is used.
(The main issue is resolved: use site-relative links.)
---
## 回覆 6
### 發文者:jmooring
**時間:18 hours ago**
**引用(quote,完全複製前文):**
> and I expect the same syntax to work whether useEmbedded is set or the almost identical custom render hook is used.
**新增回覆內容:**
The only difference between the embedded link render hook and the one I included in my example is that the embedded render hook passes the destination through (untouched) when it cannot resolve the destination to a page. The render hook in my example, on the other hand, throws an error.
---
## 回覆 7
### 發文者:ZhenShuo2021
**時間:17 hours ago**
**內容(原文):**
I understand their difference. What I’m saying is that none of your examples work when nothing is set. This is a bug.
---
## 回覆 8
### 發文者:jmooring
**時間:17 hours ago**
**引用(quote):**
> when nothing is set.
**新增回覆內容:**
What does that mean?
---
## 回覆 9
### 發文者:ZhenShuo2021
**時間:17 hours ago**
**內容(原文):**
After removing render-link.html, it still works.
After further removing the markup settings, the links break and resolve to the raw *.md files.
It can be reproduced by removing the render hook and the markup settings. It appears that the embedded render hooks are not applied when no settings are defined.
---
## 回覆 10
### 發文者:jmooring
**時間:17 hours ago**
**內容(原文):**
That’s exactly what should be happening:
[http://localhost:1313/configuration/markup/#renderhookslinkuseembedded](http://localhost:1313/configuration/markup/#renderhookslinkuseembedded)
This isn’t a bug.
---
## 回覆 11
### 發文者:ZhenShuo2021
**時間:17 hours ago**
**內容(原文):**
I don’t get it. The documentation says it uses auto if nothing is set, and auto uses the embedded render hook.
---
## 回覆 12
### 發文者:jmooring
**時間:17 hours ago**
**引用(quote,來自文件):**
> Automatically use the embedded link render hook for multilingual single-host sites.
**新增回覆內容:**
Is your site multilingual single-host? If so, what version of Hugo are you using?
---
## 回覆 13
### 發文者:ZhenShuo2021
**時間:17 hours ago**
**內容(原文):**
I pushed the changed here, please see github.com/thisuser/hugo-testing
---
## 回覆 14
### 發文者:jmooring
**時間:17 hours ago**
**內容(原文):**
Before I do that, please answer my questions.
---
## 回覆 15
### 發文者:ZhenShuo2021
**時間:17 hours ago**
**內容(原文):**
I used exactly the same site as your example. The only difference is that I removed the markup configuration and the render hook. I hope this is clear enough.
---
## 回覆 16
### 發文者:jmooring
**時間:17 hours ago**
**引用(quote):**
> Is your site multilingual single-host?
**新增回覆內容:**
Again, please answer this question.
---
## 回覆 17
### 發文者:ZhenShuo2021
**時間:16 hours ago**
**內容(原文):**
If you are referring to this:
[https://gohugo.io/content-management/page-resources/#multilingual](https://gohugo.io/content-management/page-resources/#multilingual)
the example site is a non-multilingual single-host site with no multilingual settings.
---
## 回覆 18
### 發文者:jmooring
**時間:16 hours ago**
**引用(quote):**
> Automatically use the embedded link render hook for multilingual single-host sites.
**新增回覆內容:**
I’m not sure how to make that any clearer.
---
## 回覆 19
### 發文者:ZhenShuo2021
**時間:16 hours ago**
**內容(原文):**
Sorry if I didn’t read it carefully—it only works for multilingual sites. In any case, thank you very much for the clarification. Your example is extremely helpful, and I really appreciate it.
---
## 回覆 20
### 發文者:jmooring
**時間:14 hours ago**
**引用(quote):**
> it only works for multilingual sites
**新增回覆內容:**
I’m not sure what that means.
There are four possible values for the useEmbedded configuration parameter. The fallback, always, and never options apply to both monolingual and multilingual sites.
事情是這樣的
事情是這樣的,我在論壇上面發問官方推薦的相對路徑語法是什麼,然後維護者給了一個範例 repo,在回覆 3 裡面我對 repo 進行測試除了發現一個小 bug 以外,還發現「移除 custom render hook 並且移除 config 設定之後他的範例就不再可行」,我所有在講的就只是這樣,但是他開始回我莫名其妙的話,雖然現在我能看懂他為什麼這樣講,但是我當下很不解:
- 回覆 4:Test results without the render hook in place are irrelevant. 當下感想是就已經說測試結果不同了,為什麼還回答 irrelevant?
- 回覆 5:我明確回應這個情況會使用 embedded render hook,而 embedded render hook 和他的版本只差一行錯誤處理,卻無法運行。
- 回覆 6:The only difference between the embedded link render hook... 他以為我沒看懂程式碼,這沒什麼,但是他看漏了「會使用 embedded」,問題就出在「預設情況不使用 embedded」
- 回覆 7:我當下知道他以為我沒看懂兩個 hook 差異,因此我就直接說「什麼都不設定的情況下,他的範例不起作用」
到這裡已經夠清楚了吧,我在我自己的第一個回覆(回覆 3)就已經提供完整步驟了,然後他沒仔細看,這我不怪他,那個回覆確實有點長。但是回覆 5/7 他又看漏了,我說應該使用 embedded,這個觀點不正確,如果這三次他有任何一次沒有遺漏,就不需要後續 15 個對話。
接下來從回覆 8 開始:
- 回覆 8:What does that mean? (when nothing is set) 我已經連續講三次,回覆 3 最詳細版本、回覆 5 說明移除東西、回覆 7 說「什麼都不設定」,結果我被反問這什麼意思
- 回覆 9:我 quote 我自己說的話
- 回覆 10:他貼文檔
- 回覆 12:從這裡到結尾他開始不斷反問我 multilingual single-host
到這裡我就更不能理解,我從頭到尾都在說他的 example site,不知道他反問我是想要從我這得到什麼回覆,example site 完全是他自己寫的,他是全知視角卻反問我是不是 multilingual single-host。
陳述完事實之後來說背後隱藏的細節。
請別忘了在我的視角中,他作為該範例的作者對這些設定理應熟悉,我只是在講移除 render hook 和 markup config 會出現問題,一個步驟就可以重現錯誤,但他卻反覆要求我回答相同問題。
更讓我困惑的是 example site 裡面設定了 useEmbedded,依照文檔說明,設定了 custom render hook 的情況下根本不需要設定這個,這又讓我後續的判斷多了一個「會不會是 useEmbedded 設定造成問題」的思維分支,我確實也把這個發現寫在回覆 3 了,不過我寫了他也不看。
而且我問的是「What is the officially recommended syntax for relative links?」,結果官方推薦的方式預設狀態不支援,他也沒有提醒必須添加額外設定才能運作,那是我的理解問題,還是他的回答缺少資訊?誰會知道官方建議方式在官方預設下無法運作?把重現步驟交給維護者也是標準做法卻得到這樣的回應,很遺憾標準做法在 Hugo 行不通。
老實說我感覺自己被羞辱有點 tilted,導致我沒看到他貼文檔,沒看到確實是我的錯,但是如果要打這點,他自己也多次看漏我在講的東西,而且看不看漏也無關緊要,因為就算看漏那也沒什麼大不了的,直接說「embedded render hook 在單語言網站需要額外設定才能啟用」就能簡單解決,然而以反問的方式回應造成無端多了 10 幾個來回對話,還把雙方心情都搞砸。這是一個簡單的 embedded render hook 裡面用到的 .GetPage 問題,只是單一主機多語言的網站需要額外設定才能啟用 embedded render hook,這麼簡單的事情卻因為回應方式產生不需要的爭端。
我沒有想在論壇幫自己討公道,那只是網路世界而且我也不是英語母語者沒辦法跟他吵,所以最後想了想還是簡單說了感謝和抱歉然後不再理會,這是我覺得最不浪費時間的回應方式,能把這麼簡單的答案搞成這樣我也很無奈。
這篇文章到底想表達什麼?
我根本不覺得看漏會怎麼樣,看漏是人之常情根本沒什麼大不了,寫下來是因為單看討論串不了解具體事情會覺得是我不回答問題,但是把所有經過全部講出來就知道誰才有問題。
整件事情很簡單,雙方都有看漏,但是只要直說「embedded render hook 在單語言網站需要額外設定才能啟用」就能結束的對話,卻選擇使用不斷反問用戶的方式溝通,一個好工具搭配這種回應方式非常令人遺憾。
要說我反應過於激烈,他可能沒那個意思,可客觀事實就是維護者不斷追問用戶自己清楚知道的答案,這讓我覺得不像是在解決問題,也不能說是合適的溝通方式。
愛罵又愛用?
我每次都會感謝他們的維護和社群支援,這次也同樣,我感謝他們的維護,但這不代表他們糟糕透頂的文檔不能被批評,更不代表他的回應方式正確。
你可能會說愛罵又愛用,怎樣,用了不能抱怨嗎?開源就不能發表負面意見?尤其是被這樣回覆的時候,你還要求我語氣多好?我是純黑粉只抱怨不提建議嗎?我是不是在主題端就幫他擋下了不知道有多少的問題?我是第一次遇到這種問題嗎?我是第一次被這種態度回應嗎?是誰的用字方式會造成不必要的衝突?看到維護者以這種回應方式還不能有情緒?文檔本身描述就不清楚了,問題推給用戶?就算文檔完美無暇,這種回應有必要嗎?知道答案卻不斷反問用戶是能更快解決問題還是帶來更多問題?前幾次我和他們的互動有像這次反應這麼激烈嗎?不是專案開源就可以這樣講話欸。
我在年前還想過要不要幫 Hugo 發個新年快樂感謝多年以來的付出,不過因為英文太爛所以打住,然後一個月後我被氣到寫一篇文章,短短時間之內把我轉黑,那他也是很有能耐。
免責聲明:我無法也無意判斷他的主觀意圖,本文僅描述這種回應方式造成的實際溝通效果。