How to create an attribute in Magento 2
What is an attribute?
An attribute is simply a piece of information that the customer shopping on your e-commerce store sees on the storefront.
How many attributes can you create?
There is no limit, but it is important to know that this information can affect the performance of the store: the more information there is, the more the site can slow down.
What types of attributes can you create?
- text field (255 characters)
- text area
- text editor (includes text formatting)
- page builder (lets you create HTML blocks)
- date
- date and time
- yes/no
- multiple select
- dropdown
- price
- media
- visual swatch
- text swatch
- fixed product tax

I want to point out that the only attributes that can become category or search filters are the following:
- yes/no
- multiple select
- dropdown
How do you create a new attribute?
From the admin menu, go to Stores => (Attributes) Product

This opens the attribute grid, where you click the “Add New Attribute” button at the top right.

Now all that’s left is to fill in the fields.
In the first tab, “Properties“, we have the attribute’s properties: the default label, which automatically populates the attribute code as well, the field type, and whether or not the field is required.
The advanced properties section contains the attribute code.
The scope, which tells us whether the attribute should be global or have a different value per website or store view.
An optional default value.
The option to require a unique value.
We can set a validation type.
We can add the attribute to the product grid information and/or to the filters.

If the attribute is of type Dropdown or Multiselect, there is an extra piece of configuration: the values that will be displayed.

In the second tab, “Manage Labels“, we can set a different label for each language. It makes sense to fill this in when you have a multistore setup, or when you need to translate a default attribute whose label is in English.

The third tab, “Storefront Properties“, covers the storefront settings: whether the attribute is used in search, whether it can be used to compare products, and whether it is shown in layered navigation or in promotions.
We can set the attribute’s position and decide whether to show it on the storefront in the product list or on the product page (if the attribute doesn’t need to be visible on the storefront, because it’s only useful in the admin panel, remember not to show it on the storefront, for performance reasons).

You can also create an attribute from the product create/edit page, using the button at the top right: “Add Attribute“

Finally, you can also create an attribute through an installer, that is, via code.