Create a new storefront theme

#Create a storefront theme:

Create a storefront theme steps:

1. Create a directory for the theme under
<br>`app/design/frontend/[your_vendor_name]/[your_theme_name]`.
2. Declare your theme `theme.xml`
3. Register your theme `registration.php`
4. Configure images `etc/view.xml`
5. Declare your Theme Logo
6. Configure your theme in the Admin panel.

##Create a theme directory
To create the directory for your theme:

Go to `MAGENTO_DIRECTORY`/app/design/frontend.

Under a dove directory, create the <vendor> directory, create a directory named according to your theme.
In my case I will set:
 - vendor name: `Karabiner`
 - theme name:  `green`.

```:app/design/frontend/
Karabiner
├── green/
│   ├── etc/
│   │   ├── view.xml
│   ├── web/
│   │   ├── images
│   │   │   ├── karabiner_logo.svg
│   ├── registration.php
│   ├── theme.xml
```

## Declare your theme `theme.xml`

Now we have folder `app/design/frontend/Karabiner/green`, now create a file named `theme.xml` that define basic information about the theme such as Name, parent theme (in case your theme inherits from an existing theme), preview image

```xml:app/design/frontend/Karabiner/green/theme.xml
<?xml version="1.0" encoding="UTF-8"?>
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Green</title> <!-- your theme's name -->
    <parent>Magento/blank</parent> <!-- the parent theme, in case your theme inherits from an existing theme -->
</theme>
```
## Register your theme `registration.php`

You can add the following content to register the theme to Magento 2

```php:app/design/frontend/Karabiner/green/registration.php
<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/Karabiner/green', // theme path
    __DIR__
);
```
※You should change Karabiner, green to your vendor, theme name.

##Configure images `etc/view.xml`
This is the configuration file. This file is `required`※ for Magento 2 theme.
※ - **it is optional if it exists in the parent theme.**

Go to `app/design/frontend/Karabiner/green/` and create a file `etc/view.xml`
You can copy the view.xml file in parent theme such as the `Blank` theme.
`vendor/magento/theme-frontend-blank/etc/view.xml`

```xml:app/design/frontend/Karabiner/green/etc/view.xml
<image id="category_page_grid" type="small_image">
    <width>250</width>
    <height>250</height>
</image>
```

In `view.xml`, image properties are configured in the scope of element:

```xml:app/design/frontend/Karabiner/green/etc/view.xml
<images module="Magento_Catalog">
...
<images/>
```
Image properties are configured for each image type defined by the id and type attributes of the <image> element:

```xml:app/design/frontend/Karabiner/green/etc/view.xml
<images module="Magento_Catalog">
	<image id="unique_image_id" type="image_type">
	<width>100</width> <!-- Image width in px --> 
        <height>100</height> <!-- Image height in px -->
	</image>
<images/>
```

##Declare your Theme Logo
In Magento 2 default, it uses `[theme_dir]/web/images/logo.svg`, in your theme, you can change to a different image format such as png, jpg but you have to declare it.

Logo size should be sized 300x300px and you open file `[theme_dir]/Magento_Theme/layout/default.xml`

```xml:app/design/frontend/Karabiner/green/Magento_Theme/layout/default.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_file" xsi:type="string">images/karabiner_logo.svg</argument>
                <argument name="logo_img_width" xsi:type="number">100</argument> 
                <argument name="logo_img_height" xsi:type="number">100</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>
```

## Configure your theme in the Admin panel.
####To confirm the theme successfully registered into Magento
`Admin panel -> content -> under Design -> click on Themes`
![content-design-themes.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/275433/e3478684-603f-ae5c-2b76-d6f609e83794.png)

you can see a new theme listed on the themes page.
![content-design-themes-new-theme.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/275433/a76ddc2e-8f97-bb14-f0e4-a1a1f6217a1b.png)

####To Configure the theme.
`Admin panel -> content -> under Design -> click on Configuration`

![content-design-config.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/275433/a0afca9d-185e-abf4-049b-414073935787.png)

**change default Theme and [save Configuration]**
![content-design-config-change-theme.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/275433/39261afd-3eec-a139-32b6-ae300fa03701.png)

####clear cache and check front end
you can see the logo was changed to karabiner logo  
![logo-changed.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/275433/6dd62624-ce27-4e6c-8030-24808f4882ca.png)