Clean URLs, also sometimes referred to as RESTful URLs, user-friendly URLs, pretty URLs or search engine-friendly URLs, are
URL
A Uniform Resource Locator (URL), colloquially termed as a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifie ...
s intended to improve the
usability
Usability can be described as the capacity of a system to provide a condition for its users to perform the tasks safely, effectively, and efficiently while enjoying the experience. In software engineering, usability is the degree to which a soft ...
and
accessibility
Accessibility is the design of products, devices, services, vehicles, or environments so as to be usable by people with disabilities. The concept of accessible design and practice of accessible development ensures both "direct access" (i. ...
of a
website or
web service by being immediately and intuitively meaningful to non-expert
user
Ancient Egyptian roles
* User (ancient Egyptian official), an ancient Egyptian nomarch (governor) of the Eighth Dynasty
* Useramen, an ancient Egyptian vizier also called "User"
Other uses
* User (computing), a person (or software) using an ...
s. Such URL schemes tend to reflect the conceptual structure of a collection of information and
decouple __NOTOC__
Decoupling usually refers to the ending, removal or reverse of coupling.
Decoupling may also refer to:
Economics
* Decoupling (advertising), the purchase of services directly from suppliers rather than via an advertising agency
* Deco ...
the
user interface from a server's internal representation of information. Other reasons for using clean URLs include
search engine optimization (SEO),
conforming to the
representational state transfer (REST) style of software architecture, and ensuring that individual
web resources remain consistently at the same URL. This makes the
World Wide Web a more stable and useful system, and allows more durable and reliable
bookmarking of web resources.
Clean URLs also do not contain implementation details of the underlying web application. This carries the benefit of reducing the difficulty of changing the implementation of the resource at a later date. For example, many URLs include the filename of a
server-side script
Server-side scripting is a technique used in web development which involves employing scripts on a web server which produces a response customized for each user's (client's) request to the website. The alternative is for the web server itself ...
, such as , or . If the underlying implementation of a resource is changed, such URLs would need to change along with it. Likewise, when URLs are not "clean", if the site database is moved or restructured it has the potential to cause
broken links
Broken may refer to:
Literature
* ''Broken'' (Armstrong novel), a 2006 novel by Kelley Armstrong in the ''Women of the Otherworld'' series
* ''Broken'' (Slaughter novel), a 2010 novel by Karin Slaughter
Music Albums
* ''Broken (And Oth ...
, both internally and from external sites, the latter of which can lead to removal from
search engine
A search engine is a software system designed to carry out web searches. They search the World Wide Web in a systematic way for particular information specified in a textual web search query. The search results are generally presented in a ...
listings. The use of clean URLs presents a consistent location for resources to
user-agents regardless of internal structure. A further potential benefit to the use of clean URLs is that the concealment of internal server or application information can improve the
security
Security is protection from, or resilience against, potential harm (or other unwanted coercive change) caused by others, by restraining the freedom of others to act. Beneficiaries (technically referents) of security may be of persons and social ...
of a system.
Structure
A URL will often comprise a
path, script name, and
query string. The query string parameters dictate the content to show on the page, and frequently include information opaque or irrelevant to users—such as internal numeric
identifier
An identifier is a name that identifies (that is, labels the identity of) either a unique object or a unique ''class'' of objects, where the "object" or class may be an idea, physical countable object (or class thereof), or physical noncountable ...
s for values in a
database, illegibly
encoded data,
session IDs, implementation details, and so on. Clean URLs, by contrast, contain only the path of a resource, in a hierarchy that reflects some logical structure that users can easily interpret and manipulate.
Implementation
The implementation of clean URLs involves
URL mapping via pattern matching or transparent
rewriting
In mathematics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a well-formed formula, formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewr ...
techniques. As this usually takes place on the server side, the clean URL is often the only form seen by the user.
For search engine optimization purposes, web developers often take this opportunity to include relevant keywords in the URL and remove irrelevant words. Common words that are removed include
articles and
conjunctions, while descriptive keywords are added to increase user-friendliness and improve search engine rankings.
A
fragment identifier
In computer hypertext, a URI fragment is a character string (computer science), string of character (computing), characters that refers to a resource (computer science), resource that is subordinate to another, primary resource. The primary resou ...
can be included at the end of a clean URL for references within a page, and need not be user-readable.
Slug
Some systems define a ''slug'' as the part of a URL that identifies a page in
human-readable keywords. It is usually the end part of the URL (specifically of the
path /
pathinfo part), which can be interpreted as the name of the resource, similar to the
basename in a
filename
A filename or file name is a name used to uniquely identify a computer file in a directory structure. Different file systems impose different restrictions on filename lengths.
A filename may (depending on the file system) include:
* name &ndas ...
or the title of a page. The name is based on the use of the word ''
slug
Slug, or land slug, is a common name for any apparently shell-less terrestrial gastropod mollusc. The word ''slug'' is also often used as part of the common name of any gastropod mollusc that has no shell, a very reduced shell, or only a smal ...
'' in the news media to indicate a short name given to an article for internal use.
Slugs are typically generated automatically from a page title but can also be entered or altered manually, so that while the page title remains designed for display and human readability, its slug may be optimized for brevity or for consumption by search engines, as well as providing recipients of a shared bare URL with the rough idea of the page's topic. Long page titles may also be truncated to keep the final URL to a reasonable length.
Slugs may be entirely lowercase, with accented characters replaced by letters from the
Latin script and
whitespace characters replaced by a
hyphen or an
underscore to avoid being
encoded. Punctuation marks are generally removed, and some also remove short, common words such as
conjunctions. For example, the title ''This, That, and the Other! An Outré Collection'' could have a generated slug of .
Another benefit of URL slugs is the facilitated ability to find a desired page out of a long list of URLs without page titles, such as a minimal list of opened
tabs exported using a
browser extension
A browser extension is a small software module for customizing a web browser. Browsers typically allow a variety of extensions, including user interface modifications, cookie management, ad blocking, and the custom scripting and styling of web p ...
, and the ability to preview the approximate title of a target page in the browser if
hyperlink
In computing, a hyperlink, or simply a link, is a digital reference to data that the user can follow or be guided by clicking or tapping. A hyperlink points to a whole document or to a specific element within a document. Hypertext is text wit ...
ed to without title.
Should a tool to save web pages locally using the string after the last slash as the default
file name, like
wget does, a slug makes the file name more descriptive.
Websites that make use of slugs include
Stack Exchange Network
Stack Exchange is a network of question-and-answer (Q&A) websites on topics in diverse fields, each site covering a specific topic, where questions, answers, and users are subject to a reputation award process. The reputation system allows th ...
with question title after slash, and
Instagram
Instagram is a photo and video sharing social networking service owned by American company Meta Platforms. The app allows users to upload media that can be edited with filters and organized by hashtags and geographical tagging. Posts can ...
with
?taken-by=''username''
URL parameter.
See also
*
Information architecture
*
Permalink
*
Persistent uniform resource locator (PURL)
*
URL normalization
*
URL redirection
*
URL shortening
*
*
Canonical link element
References
{{reflist
External links
URL as UI by
Jakob Nielsen Jacob or Jakob Nielsen may refer to:
* Jacob Nielsen, Count of Halland (died c. 1309), great grandson of Valdemar II of Denmark
* , Norway (1768-1822)
* Jakob Nielsen (mathematician) (1890–1959), Danish mathematician known for work on automorphi ...
The User Interface of URLsCool URIS don't change by
Tim Berners-Lee
Sir Timothy John Berners-Lee (born 8 June 1955), also known as TimBL, is an English computer scientist best known as the inventor of the World Wide Web. He is a Professorial Fellow of Computer Science at the University of Oxford and a profess ...
Search engine optimization
URL