Using relative URLs

Managed by | Updated .

Always prefer using relative URLs when linking separate resources (where appropriate), by order of preference:

  • Completely relative URLs under /s/ (e.g. href="search.html", src="resources/images/image.png")
  • Absolute URLs without a domain name (e.g. href="/s/search.html", src="/s/resources/images/images.png")
  • URLs with a domain name, but without a protocol, for HTTP/HTTPS compatibility (e.g. href="//")
  • collection.cfg options such as ui.modern.search_link.

This applies to:

  • resources linked from search templates
  • resources linked from CSS files (e.g. background: url('/s/resources/...'); )

Doing so makes your collection more portable, as there will be nothing to change when it moves across servers. Additionally it makes testing easier by avoiding various problems with cross-domain requests and/or HTTP vs HTTPS requests.

Was this artcle helpful?

Features: Frontend > Templating