Register Assets In Template Of Module

I have a module and wanna to create its template.i create assets folder and it’s sub folders and layouts folder in my module and use it in layout :

use app\modules\blog\assets\BlogAsset;

my asset class is below code, after i render my layout of modules ,assets is created in web/assets but it not registered in head of html ?!



 * @link

 * @copyright Copyright (c) 2008 Yii Software LLC

 * @license


namespace app\modules\blog\assets;

use yii\web\AssetBundle;


 * @author Qiang Xue <>

 * @since 2.0


class BlogAsset extends AssetBundle


        public $sourcePath='@app/modules/blog/assets';

	public $css = [





Thank’s for Solutions !

How have your registered the BlogAsset in your view layout? You mentioned only the use of the namespaced asset. You should also have registered this bundle in your view layout file in the beginning.

// views/layouts/main.php

use app\modules\blog\assets\BlogAsset;


maybe there is no




in your layout

Yes,That’s it.

Its better to sometimes copy the Yii default app view layout file - and edit over it so you do not miss such important elements :).