Answers.Body: <p>You need to register asset bundles in your plugin, see the Craft docs -> <a href="https://docs.craftcms.com/v3/extend/asset-bundles.html" rel="nofollow noreferrer">https://docs.craftcms.com/v3/extend/asset-bundles.html</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-05T12:22:28.433Z
Answers.LastActivityDate: 2020-06-05T12:22:28.433Z
Answers.UserDisplayName: dmatthams
Body: <p>I am trying to build a basic plugin, when installed has a single nav bar item, and of course a twig template which shows up on clicking on that navbar item.</p>
  
  <p>I have used the basic template to extend to make my page:</p>
  
  <pre><code>{% extends "_layouts/cp" %}
  {% set title = "Page Title"|t('plugin-handle') %}
  
  {% block content %}
      &lt;p&gt;Page content goes here&lt;/p&gt;
  {% endblock %}
  </code></pre>
  
  <p>The resulting page for the plugin looks like shown in the screenshot attached below:</p>
  
  <p><a href="https://i.sstatic.net/0OB0l.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0OB0l.png" alt="Screenshot of basic template"></a></p>
  
  <p>Now I am trying to add content in the content section, but I am not sure how to add my assets</p>
  
  <p><code>&lt;img src="/resources/img/poptinlogo.png"/&gt;</code></p>
  
  <p>This won't work, and I am guessing I need to get the paths using some variable in the twig templating system, but I am not sure how. And the documentation is not clear on this part, or maybe I don't know where to look right away.</p>
  
  <p>How to include my assets on the page, like images, js and css files?</p>
  
Tags: <plugin-development><templating><craft3><php>
Title: How to use assets while building Craft CMS plugins?
ThreadText: # How to use assets while building Craft CMS plugins?
  
  (Asked by: username_0 on 2020-06-05)
  
  I am trying to build a basic plugin, when installed has a single nav bar item, and of course a twig template which shows up on clicking on that navbar item.
  
  I have used the basic template to extend to make my page:
  
  ```
  {% extends "_layouts/cp" %}
  {% set title = "Page Title"|t('plugin-handle') %}
  
  {% block content %}
      <p>Page content goes here</p>
  {% endblock %}
  
  ```
  
  The resulting page for the plugin looks like shown in the screenshot attached below:
  
  [![Screenshot of basic template](https://i.sstatic.net/0OB0l.png)](https://i.sstatic.net/0OB0l.png)
  
  Now I am trying to add content in the content section, but I am not sure how to add my assets
  
  `<img src="/resources/img/poptinlogo.png"/>`
  
  This won't work, and I am guessing I need to get the paths using some variable in the twig templating system, but I am not sure how. And the documentation is not clear on this part, or maybe I don't know where to look right away.
  
  How to include my assets on the page, like images, js and css files?
  
  **Tags:** plugin-development, templating, craft3, php
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-06-05. Score: 2 | Accepted answer
  
  You need to register asset bundles in your plugin, see the Craft docs -> <https://docs.craftcms.com/v3/extend/asset-bundles.html>
  
  
  ---
  
  