cancel
Showing results for 
Search instead for 
Did you mean: 

magento styles doesnt work on controller page (wrong link to css)

magento styles doesnt work on controller page (wrong link to css)

Hello. 

I am using magento 2 with a custom theme. When I try create new controller with action it loads fine but all css/js links on that page looks not correct and not loading. 

 

Code of Index.php

<?php

namespace TestProject\HelloWorld\Controller\Index;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;

class Index extends Action implements HttpGetActionInterface
{
    public function execute()
    {
        return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
    }
}

When I load default pages (for example homepage) CSS styles links looks like this (CustomTheme/WorkTeam - it is a name of the my custom theme)

/static/frontend/CustomTheme/WorkTeam/en_US/css/styles-m.css

but from my helloworld/index/index all links on CSS and JS files have 

/static/frontend/_view/en_US/css/styles-m.css

Code generate wrong path with "_view" in link and those files not loading. What I am doing wrong?

 

Duke