How to create a new module in Magento 2

app/
└── code/
    └── Leela/
        └── RemoveNewsLetter/
            ├── registration.php
            └── etc/
                └── module.xml
            └── view/
                └── frontend/
                    └── layout/
                        └── default.xml

in the app/code directory of your Magento installation.

The directory structure should be: app/code/Leela/RemoveNewsLetter/.

Create “app/code/Leela/RemoveNewsLetter/registration.php

with the following content:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Leela_RemoveNewsLetter',
    __DIR__
);

app/code/Leela/RemoveNewsLetter/etc/module.xml

with the following content:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Leela_RemoveNewsLetter" setup_version="1.0.0" />
</config>

app/code/Leela/RemoveNewsLetter/view/frontend/layout/default.xml

with the following content:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="form.subscribe" remove="true" />
    </body>
</page>

Run the following command in your root directory

php bin/magento setup:upgrade

That’s it! The above module will remove the newsletter section from your Magento store’s frontend.