Deutsch
URLs & domains

Query string

Also known as: query component

The query string is the part of a URL that starts with a question mark (?) and carries additional data as key and value pairs. In RFC 3986 this part is called the query component.

How is a query string built?

Text
https://example.com/search?q=shoes&page=2
  • ? marks the start of the query string.
  • = joins a key to its value.
  • & separates multiple pairs.

The string ends at the fragment (#) or at the end of the URL. When a value contains special characters, they are percent-encoded. MDN notes that URL.search encodes a space as %20, whereas URLSearchParams uses +.

Single pairs inside it are what many SEO texts call URL parameters. The two terms are often used interchangeably, and some authors use “query string” for the whole part and “parameters” for each pair.

Anatomy of a URLThe example URL https://shop.example.de/shoes/sneakers/?color=red&page=2#reviews broken into parts: scheme https, host shop.example.de with subdomain shop, domain example.de and top-level domain de, path /shoes/sneakers/ with a trailing slash, query string with two parameters color=red and page=2, fragment reviews. The fragment is not sent to the server.Trailing slashhttps://shop.example.de/shoes/sneakers/?color=red&page=2#reviewsSchemeHostPathQuery stringFragmentSubdomainDomainParameterParameterTLDcountry code: ccTLDstays in the browser, is notsent to the serverSchematic. Scheme, host, path, query and fragment are components defined in RFC 3986.Subdomain, domain and TLD split the host by DNS level. Without a port, https uses port 443.
A URL broken into its parts. RFC 3986 defines scheme, host, path, query and fragment. Only the browser evaluates the fragment after #, it is not sent to the server. Sources: RFC 3986: Uniform Resource Identifier (URI), Generic Syntax; MDN: What is a URL?; MDN Glossary: TLD.

Why does it matter for SEO?

Every different query string creates a different URL. Google recommends = and & as separators and advises trimming parameters that do not change the content to keep URLs short and prevent crawler bloat. Where parameters create many variations, the page-level handling covers canonical tags, robots.txt rules or internal linking.

Example

For https://example.com/search?q=shoes&page=2, a script reads q as shoes and page as 2. A search engine sees the URL as a separate address from https://example.com/search.

Common mistakes

  • Parameters that do not change the content. Google advises limiting parameters to those that affect the content, because otherwise many URLs exist for the same content.
  • Session IDs in URLs. Google recommends avoiding them where possible and using cookies instead.
  • Inconsistent casing. Google treats /APPLE and /apple as distinct URLs. Converting all text to the same case makes it easier for Google to see that URLs reference the same page.
  • Changing content through the fragment. Google states that Search generally does not support URL fragments, so content that should change needs its own URL.

Sources

  1. URL: search property – MDN Web Docsdeveloper.mozilla.org
  2. RFC 3986, section 3.4 Query – IETFrfc-editor.org
  3. URL structure best practices for Google Search – Google Search Centraldevelopers.google.com

Last updated: