尤川豪   ·  5月前
Exp. 1,630  ·  212 貼文  ·  145 留言

URL 網址設計該用單數還是複數?

單數派

todo

複數派

Facebook

https://www.facebook.com/groups
https://www.facebook.com/groups/remotetaiwan/
https://www.facebook.com/pages
https://www.facebook.com/messages/t/
https://www.facebook.com/events/
https://www.facebook.com/events/2064662180513132/

Reddit

https://www.reddit.com/r/PHP/comments/9v1gil/php2go/

Google

google.com/analytics
google.com/analytics/settings
google.com/analytics/feeds
google.com/books
google.com/catalogs
google.com/maps
google.com/places
google.com/trends

Bing

bing.com/images
bing.com/maps
bing.com/results
bing.com/videos

Stack Overflow

stackoverflow.com/users/
stackoverflow.com/feeds/
stackoverflow.com/questions/
stackoverflow.com/tags/
stackoverflow.com/help/badges

混合派

Reddit

https://www.reddit.com/r/PHP/comments/9v1gil/php2go/
https://www.reddit.com/user/howtomakeaturn

refs:

https://serverfault.com/questions/73682/standard-for-singular-vs-plural-type-names-in-urls

  分享   共 417 次點閱
共有 2 則留言
Connor Hsu   ·  5月前
Exp. 62  ·  0 貼文  ·  7 留言

印象中 RESTful API 設計的建議是一般用複數

但是在對使用者來說是單一資源的時候,則用單數

比如使用者自己的資訊用 /user,但自己相簿裡的照片用 /images

這就可以解釋為什麼你 Reddit 的例子是混合的了

 
尤川豪   ·  5月前
Exp. 1,630  ·  212 貼文  ·  145 留言

原來如此

不過我找到一篇說的也不錯 他是連單一資源也一併用複數 讓網址類似資料夾路徑結構

用戶可以在 url 內刪掉最後一個單字回到上一層 我上網時 有時的確也會這麼做

https://webmasters.stackexchange.com/questions/4930/should-i-use-plural-or-singular-parts-for-my-url-when-on-a-listing-page

My preferred approach is face a website like a directories structure. This gives more semantic, and makes easier to power users to predict listing directories.

In your case:

www.mysite.com/              #root
www.mysite.com/stores/       #stores listing
www.mysite.com/stores/paris  #paris store details

Note the predictable structure. Trailing slash let people and crawlers understand that it threats about a directory root.

Power users that land in paris store for example, can be tempted to just delete "paris" from URL and expect to see the parent list or something like that (they tend to face URLs as breadcrumbs). This is why I think this approach is the more interesting.

 
您的留言
尤川豪
Exp. 1,630  ·  212 貼文  ·  145 留言

關於作者

Devs.tw 作者,喜歡分享&建造新東西的工程師。

歡迎在 Facebook 追蹤我!不定期分享有趣技術文章!

  查看個人檔案