Clean URLs (also known as user-friendly URLs, pretty URLs, search-engine–friendly URLs or RESTful URLs) are web addresses or
Uniform Resource Locators (URLs) intended to improve the
usability and
accessibility of a
website
A website (also written as a web site) is any web page whose content is identified by a common domain name and is published on at least one web server. Websites are typically dedicated to a particular topic or purpose, such as news, educatio ...
,
web application, or
web service
A web service (WS) is either:
* a service offered by an electronic device to another electronic device, communicating with each other via the Internet, or
* a server running on a computer device, listening for requests at a particular port over a n ...
by being immediately and intuitively meaningful to non-expert
users. Such URL schemes tend to reflect the conceptual structure of a collection of information and
decouple the
user interface
In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine fro ...
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
The World Wide Web (WWW or simply the Web) is an information system that enables Content (media), content sharing over the Internet through user-friendly ways meant to appeal to users beyond Information technology, IT specialists and hobbyis ...
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, 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, both internally and from external sites, the latter of which can lead to removal from
search engine
A search engine is a software system that provides hyperlinks to web pages, and other relevant information on World Wide Web, the Web in response to a user's web query, query. The user enters a query in a web browser or a mobile app, and the sea ...
listings. The use of clean URLs presents a consistent location for resources to
user agent
On the Web, a user agent is a software agent responsible for retrieving and facilitating end-user interaction with Web content. This includes all web browsers, such as Google Chrome and Safari
A safari (; originally ) is an overland jour ...
s 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 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
identifiers for values in a
database
In computing, a database is an organized collection of data or a type of data store based on the use of a database management system (DBMS), the software that interacts with end users, applications, and the database itself to capture and a ...
, 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 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 can be included at the end of a clean URL for references within a page, and need not be user-readable.
Slug
The name ''
slug
Slug, or land slug, is a common name for any apparently shell-less Terrestrial mollusc, 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 ...
'' is based on the use of ''slug'' by the news media to indicate a short name given to an article for internal use. Some systems define a ''slug'' as the part of a URL that identifies a page in
human-readable keywords, while others use a broader definition emphasizing that legible slugs are more user-friendly. 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 file system. Different file systems impose different restrictions on filename lengths.
A filename may (depending on the file system) include:
* name – base ...
or the title of a page.
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 a 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
The Latin script, also known as the Roman script, is a writing system based on the letters of the classical Latin alphabet, derived from a form of the Greek alphabet which was in use in the ancient Greek city of Cumae in Magna Graecia. The Gree ...
and
whitespace characters replaced by a
hyphen
The hyphen is a punctuation mark used to join words and to separate syllables of a single word. The use of hyphens is called hyphenation.
The hyphen is sometimes confused with dashes (en dash , em dash and others), which are wider, or with t ...
or an
underscore
An underscore or underline is a line drawn under a segment of text. In proofreading, underscoring is a convention that says "set this text in italic type", traditionally used on manuscript or typescript as an instruction to the printer. Its ...
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 from a long list of URLs without page titles, such as a minimal list of opened
tabs exported using a
browser extension, 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 providing direct access to Data (computing), data by a user (computing), user's point and click, clicking or touchscreen, tapping. A hyperlink points to a whole document or to ...
ed without title.
If a tool to save web pages locally uses 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 with question title after slash, and
Instagram
Instagram is an American photo sharing, photo and Short-form content, short-form video sharing social networking service owned by Meta Platforms. It allows users to upload media that can be edited with Social media camera filter, filters, be ...
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
Notes
/>
References
{{reflist
External links
URL as UI
by Jakob Nielsen
The User Interface of URLs
Cool URIs don't change
by Tim Berners-Lee
Search engine optimization
URL