0

I have just started with the theme development in the magetento 2.1. I am over all new to magento. I wanted to know the setup and the ways to one develop a theme in magento . After a lot of reading the procedure i follow after making a change in the custom theme file is

  1. When changing/overriding the layout file run the 'php bin/magento setup:static-content:deploy --theme vendor/theme' command.
  2. When changing/overriding the less files/static files using grunt i run 'grunt exec:vendor && grunt less:vendor'. (Offcourse after configuring grunt).

But if instead of modifying the files from the app/design/frontend/vendor/theme/ if i modify the less/static files from 'pub/static/frontend/vendor/theme/en_US/' I can just run grunt less:vendor and i can get the compiled css there and after my development is done i can copy the files back to app/design/frontend folder at respective places.

What are the best practices or the common way of theme development steps?

PS: All vendor is your vendor and all theme is respective theme name.

1 Answers1

1

Question 1 - PHTML templates and layout XML changes

For development purposes you should be running in developer mode, to check this you can run php bin/magento deploy:mode:show. If you need to set it to developer mode use php bin/magento deploy:mode:set developer.

When in developer mode you do not need to run the static-content:deploy command, this is only for production mode. All you'll need to do when changing a layout or template file (PHTML) is to clear your cache (layout and block cache if you want to be specific).

Question 2 - Static assets (JS, CSS etc)

When changing static assets you do not need to run exec, this sets up symlinks so it's only useful when you have added or removed a file. If all you have done is change some styling you'll only need to run the grunt less:theme task.

If you've changed other static assets such as Knockout HTML templates or a JS file in most cases clearing your browser cache is enough.

If you make a change and it isn't being shown no matter what you do it's normally a good idea to clear the following directories:

var/view_preprocessed
var/cache
var/page_cache
pub/static/frontend

And if it's backend/module related also remove

var/di
var/generation

Links

And for an answer on how to develop a theme from scratch please see my answer here.

I'd also recommend reading the front-end dev docs pages

Ben Crook
  • 15,685
  • 3
  • 52
  • 104
  • How about if i am adding a new play_layout apart from "1column.xml" etc I tried that but it is not coming in the dropdown of the new page that i create from the admin panel. – Ritesh Ranjan May 26 '17 at 16:56
  • You'll likely need to clear cache and possibly log out of the admin then log back in. If this doesn't work I think there is something wrong with the code. – Ben Crook May 30 '17 at 09:14