I developed a new extension. I have some CSS which I need to include on some templates.
CSS:
app\code\Fekete\Newsletter2Go\view\frontend\web\css\main.css
Block:
\app\code\Fekete\Newsletter2Go\Block\Form.php
Template:
app\code\Fekete\Newsletter2Go\view\frontend\templates\subscribe.phtml
The template is getting called in a CMS page:
{{block class="Fekete\Newsletter2Go\Block\Form" template="Fekete_Newsletter2Go::subscribe.phtml"}}
How can I include the CSS main.css in my template?
I solved it like this, it works... but in the developer documentation they say that we should not include css in the template.
<link rel="stylesheet" href="<?= $this->getViewFileUrl('Fekete_Newsletter2Go::css/main.css'); ?>"/>
{{block class="Fekete\Newsletter2Go\Block\Form" template="Fekete_Newsletter2Go::subscribe.phtml"}}