Upgrade Your Drupal Skills
We trained 1,000+ Drupal Developers over the last decade.
See Advanced Courses NAH, I know EnoughPrint your theme's logo path in Drupal 8 with Twig
Parent Feed:
I'm updating a Drupal 6 theme to Drupal 8. One thing I'm doing is making the logo in my Twig template a Twig variable instead of hardcoding the path. Here's how you do it. This assumes a theme named 'acton', but you'll change that to your own theme's name.
In 'acton.theme', assuming your logo is 'logo.png' in your theme's root:
function acton_preprocess_page(&$variables) { $variables['logopath'] = '/' . drupal_get_path('theme','acton') . '/logo.png'; }
In your Twig template, do something like this:
<img class="img-responsive" src="http://www.lohmeyer.rocks/blog/2015/01/14/00187-print-your-themes-logo-path-drupal-8-twig/{{ logopath }}" />
Done!
About Drupal Sun
Drupal Sun is an Evolving Web project. It allows you to:
- Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
- Facet based on tags, author, or feed
- Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
- View the entire article text inline, or in the context of the site where it was created
See the blog post at Evolving Web