Multilingual site along base_path cause errors in twig

Created on 15 May 2021, almost 4 years ago
Updated 25 April 2025, 1 day ago

Problem/Motivation

In a twig file I used {{ base_path ~ directory }}/assets/image/some-image.png to print an image in markup, the problem is everything works ok when site is in default language, but when navigating to other languages, it affects the base url and cause not found error

Steps to reproduce

- navigate to www.example.com/admin/config/regional/language/detection/url and set url language detection to Path Prefix
- in a markup file access an assets using {{ base_path ~ directory }}/assets/YOUR_FILE_PATH
- change site language and you will face file not found error

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component

language system

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    Came up as daily BSI target.

    Wonder if you are still experiencing this in D11? I tried replicating but not sure I'm seeing it.

Production build 0.71.5 2024