So that you’ve determined to create a block theme however unsure the place to begin? On this information I provides you with an summary of a block theme’s file construction. In different phrases, the block theme “anatomy”. What folders & recordsdata could be inside a block theme, which of them are required and what all of them do.
To start out, I like to recommend you obtain the twenty twenty 4 theme. This manner you could have one thing you may have a look at after which modify to create your individual block theme.
Vital: This information assumes you might be an skilled WordPress developer however are unfamiliar with block themes. Maybe you could have solely labored with basic themes prior to now. I’m additionally not going to clarify how you can create and modify block theme recordsdata. The aim of this text is just to indicate you what recordsdata make up a block theme & what they’re used for.
쉬운 목차
Block Theme Construction
A primary block theme consists of a folder with a method.css file and a templates/index.html file inside. The construction of a extra strong theme could look one thing like the next screenshot taken from our Mesa WPEX theme.
Under you can see varied tables with all of the required and optionally available folders and recordsdata that make up a WordPress block theme.
Required Folders
The next folders are required inside your block theme:
Non-compulsory Folders
Technically you may add ANY folder inside your block theme. The next are optionally available folders you may add that WordPress will use for particular functions.
Required Information
The next recordsdata are the ONLY ones required for a block theme to indicate up within the WordPress admin and performance.
Required Information for the WordPress.org Repository
The next recordsdata are required in your block theme if you happen to plan to add it to the WordPress repository.
Non-compulsory Information
Technically talking ANY file or folder could be added inside your block theme, so maintain this in thoughts. Nonetheless, there are particular folders and recordsdata you may add to your block theme to perform varied duties.
Block Theme Template Information Record
When creating your block theme you received’t simply have a template/index.html file. You’ll want to create totally different layouts for the totally different components of your website. Under is a listing of the totally different template recordsdata you may add to your block theme. WordPress will robotically select and show the suitable template primarily based on visited web page.
The next template recordsdata could be added to your block theme’s templates folder to change the show of assorted components of your website.
Block Themes are Easy!
As you may see there are only a few recordsdata required to create a block theme however there are lots of optionally available recordsdata. The block theme file and template construction is definitely quite simple and simple to grasp. Hopefully if you happen to had been a bit misplaced, this information helped you.
Let me know within the feedback under when you have any questions or points.