This question already has an answer here:

I am trying to add a link into the HTML head from (content/configuration/html) head section in the backend(admin) to a file that's located in my pub/static/version*****/frontend/ folder.

How can I link to this folder without using an absolute path?


marked as duplicate by Amit Bera magento2 Sep 11 at 7:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


use Magento\Framework\View\Asset\Repository

 $asset = $this->assetRepository->createAsset('Magento_Catalog::images/image.png');
 $asset = $this->assetRepository->createAsset('My_Module::images/image.png');


$asset = $this->assetRepository->createAsset('images/image.png');

use Magento\Framework\View\Asset\File

// Get the file url

// Get the file path

// Get the content of the file

Not the answer you're looking for? Browse other questions tagged or ask your own question.