Blog Sections Open

Fixing Root-Relative Asset Paths on Subfolder and Staging URLs

An asset path that works on localhost can break immediately once the site lives in a subfolder or a nested staging URL.

the original question here was simple: why do image paths like /assets/images/... sometimes stop resolving correctly when the site is moved or opened through a different URL structure?

The core issue

Root-relative paths are resolved from the web root, not from the current document path. That is usually good, but it becomes confusing when the project is tested inside nested local URLs, mirrored folders, or staging environments where the visible URL does not match the final deployment shape.

Example

http://localhost/assets/images/...

If the project is actually being served under something closer to:

http://localhost/site.ru/assets/images/...

then the path assumptions are already different.

How to avoid fragile paths

  • use a proper base URL strategy and keep it consistent across environments
  • generate asset URLs from configuration or template helpers instead of concatenating them ad hoc
  • avoid mixing absolute, root-relative, and document-relative styles inside the same theme

The practical lesson is that path bugs are often environment bugs. Fix the URL strategy once, then render asset paths from that strategy everywhere.

Newer post

Adding rel="canonical" to Evolution CMS Templates

A practical guide to adding canonical tags in Evolution CMS templates when multiple URLs or duplicate paths can point to the same content.

Older post

When title and H1 Should Not Be the Same

Why the browser title and the visible H1 heading should often differ in Evolution CMS, especially on editorial and SEO-heavy pages.