Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
路由
|
151
绝不要使用空格和不可打印的字符
并不推荐在
URL
中包含空格。因为空格通常会被转换为一个加号(
+
)
,从而引起混淆。
显而易见,你也应该避免使用不可打印的字符。我要严肃地告诫你,不要使用任何除字
母、数字、连字符和下划线以外的字符。否则即使一时显得很“聪明”,这种“聪明”
也是经不住时间考验的。如果你的网站不是面向英语用户的,当然可以使用非英语字符
(使用百分号编码),可是如果想给你的网站做本地化,这些字符就是你头疼的根源。
在 URL 中使用小写字母
这条建议会引起一些争议。有些人不仅可以接受混合大小写,而且认为这么做更好。对
此,我不想卷入一种教徒式的争论,但我想指出,都用小写的优势是它可以通过代码自
动生成。要是你曾经不得不遍历整个网站来剔除数千个链接或做字符串比较,就会赞成
这个理由。我个人感觉小写的
URL
更有美感,但最终还是由你来决定。
14.1
 路由与
SEO
如果你希望你的网站可以被人发现(大多数人会希望),那就需要考虑一下
SEO
以及
URL
是如何影响它的。尤其是,如果有某些关键字很重要,
并且本身是有意义的
,那就考虑把
它们放入
URL
里
。例如,草地鹨旅游提供了几个俄勒冈海岸的度假产品。为了让这些产
品在搜索引擎中获得高权重,我们在网页
title
、标题栏
、内容主体、网页元信息描述中都
使用了“
Oregon
Coast
”,
而且让
URL
都以
/vacations/oregon-coast
开头。俄勒冈的海滨小镇
Manzanita
,它的度假产品包位于
/vacations/oregon-coast/manzanita ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099