{"id":56323,"date":"2023-01-06T23:01:48","date_gmt":"2023-01-06T17:31:48","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=56323"},"modified":"2023-01-22T23:12:50","modified_gmt":"2023-01-22T17:42:50","slug":"steps-of-creating-drupal-theme","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/steps-of-creating-drupal-theme\/","title":{"rendered":"Steps of creating Drupal theme"},"content":{"rendered":"<h2><span style=\"font-weight: 400;\">Introduction<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">A theme is a collection of files that implements the look of the site. They simply implement the HTML, the CSS, and JavaScript that will be making our site unique. They also consist of a bit of simple logic that is used to make our website reuse or switch markup in different cases.<\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><span style=\"font-weight: 400;\"><strong>STEP 1<\/strong><\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\">First, we need to create a custom theme under the \u2018web\/themes\/custom folder. We will name the folder as vetenary (say). You can put any name but in my case, I take it vetenary .<\/span><\/p>\n<p><strong><span style=\"color: #212529;\"><span style=\"font-family: Source Sans Pro, sans-serif;\"><span style=\"font-size: x-large;\"><b><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56315 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-23-47.png\" alt=\"\" width=\"371\" height=\"245\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-23-47.png 371w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-23-47-300x198.png 300w\" sizes=\"(max-width: 371px) 100vw, 371px\" \/><\/b><\/span><\/span><\/span><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>STEP 2<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Next, we will need to create an info.yml file. We need to specify the primary keys for it.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56316 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-25-46.png\" alt=\"\" width=\"580\" height=\"173\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-25-46.png 580w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-25-46-300x89.png 300w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\"><strong>STEP 3<\/strong><\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\">We have to make CSS and JS folder under which we have to place all our CSS and JS files.<\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>STEP 4<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\">In step 3, we have to create a libraries.yml file to specify all the libraries we need for our custom theme. We will also create CSS and JS directory and its files to link it here.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56317 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-30-18.png\" alt=\"\" width=\"639\" height=\"280\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-30-18.png 639w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-30-18-300x131.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-30-18-624x273.png 624w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Note: We have to give 2 spaces before the version, CSS and js, and 4 spaces before the theme.<\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>STEP 5<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\">After creating the libraries.yml file, we need to link it to our theme. For this, we will add it to the info.yml file which will then apply to the whole theme.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56319 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-35-12.png\" alt=\"\" width=\"607\" height=\"265\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-35-12.png 607w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-35-12-300x131.png 300w\" sizes=\"(max-width: 607px) 100vw, 607px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Note &#8211; The key will be libraries and the rule for defining the path of the theme &#8211; \u2018vetenary\u2019 \/ library name -\u2018global-styling\u2019.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong><span style=\"text-decoration: underline;\">STEP 6<\/span><\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this step, we will define the regions for our theme. In info.yml, we have to define it under the \u2018regions\u2019 key.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56318 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-41-46.png\" alt=\"\" width=\"603\" height=\"670\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-41-46.png 603w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-41-46-270x300.png 270w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>STEP 7<\/strong><\/span><\/p>\n<p>Now we have to create a folder name as a template under which we have to place our twig files.<\/p>\n<p><strong><span style=\"color: #212529;\"><span style=\"font-family: Source Sans Pro, sans-serif;\"><span style=\"font-size: x-large;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56320 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-46-59.png\" alt=\"\" width=\"326\" height=\"109\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-46-59.png 326w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-46-59-300x100.png 300w\" sizes=\"(max-width: 326px) 100vw, 326px\" \/><\/span><\/span><\/span><\/strong><\/p>\n<p>Inside the template folder, we have to override our page.html.twig.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56321 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-50-12.png\" alt=\"\" width=\"825\" height=\"700\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-50-12.png 825w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-50-12-300x255.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-50-12-768x652.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/Screenshot-from-2022-11-07-15-50-12-624x529.png 624w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>STEP 8<\/strong><\/span><\/p>\n<p>Now Go to Appearance in your Drupal site. You can see your custom Drupal theme present in the Uninstalled themes section. You need to click the \u2018Install and set as the default option to install your Drupal theme on the site.<\/p>\n<p><span style=\"color: #393939;\"><span style=\"font-family: Source Sans Pro, sans-serif;\"><span style=\"font-size: x-large;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56322 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/sc.png\" alt=\"\" width=\"1378\" height=\"935\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/01\/sc.png 1378w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/sc-300x204.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/sc-1024x695.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/sc-768x521.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/01\/sc-624x423.png 624w\" sizes=\"(max-width: 1378px) 100vw, 1378px\" \/><\/span><\/span><\/span><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Additional information<\/strong><\/span><\/p>\n<p>If you want to apply the screenshot to your theme, then you have to put a .png file inside your theme folder, and also want to apply the logo to your custom theme, then you have to put a logo.png file inside the theme folder.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Introduction A theme is a collection of files that implements the look of the site. They simply implement the HTML, the CSS, and JavaScript that will be making our site unique. They also consist of a bit of simple logic that is used to make our website reuse or switch markup in different cases. STEP [&hellip;]<\/p>\n","protected":false},"author":1510,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":9},"categories":[3602],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56323"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1510"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=56323"}],"version-history":[{"count":4,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56323\/revisions"}],"predecessor-version":[{"id":56465,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56323\/revisions\/56465"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=56323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=56323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=56323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}