Answers.Body: <p>Inside of the <code>&lt;form action="{{ url('search/results') }}"&gt;</code> You define which page should be redirected to when the search form is submitted.</p>
  
  <p>"search/results" would go to the search folder looking for the results.(html / twig). </p>
  
  <p>If you want to redirect to another page you should name the folder (which is "search" now) then the template name. This can be static without creating a "Single" for that page. </p>
  
  <p>If you did create a single that uses that template and you want to go through your single you can just put the slug of the created Single inside your form action.</p>
  
  <p><strong>Example:</strong></p>
  
  <p>You made a folder in craft/templates/ named: search, inside that folder you make a file named: results.</p>
  
  <p>So the file structure would be craft/templates/search/results.twig and the form action would be: <code>&lt;form action="{{ url('search/results') }}"&gt;</code></p>
  
  <p>This way you can just use the preset search template the craft docs offer you. You could also change "results.twig/html" to index.html and then your form action wouldn't need the /results so your action would look like:
  <code>&lt;form action="{{ url('search') }}"&gt;</code></p>
  
  <p>But I see you get redirect to /index.php/ aswell so I should try rmeoving that by changing your <code>.htaccess</code> file and maybe your general.php.</p>
  
  <p>You can find instructions on how to do that here:
  <a href="https://craftcms.com/support/remove-index.php" rel="nofollow noreferrer">https://craftcms.com/support/remove-index.php</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-16T12:44:01.760Z
Answers.LastActivityDate: 2017-03-16T12:44:01.760Z
Answers.UserDisplayName: Justin Dekkers
Body: <p>Well, to be honest i am completely new, not only to Craft but to most PHP stuff as well.
  I am currently trying to setup a search for my page but i seem to miss a crucial step and can not find any tutorials on what to do.</p>
  
  <p>On my front/ index page i included</p>
  
  <pre><code>&lt;form action="{{ url('search/results') }}"&gt;
  &lt;input type="search" name="q" placeholder="Search"&gt;
  &lt;input type="submit" value="Go"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>as stated in the Craft Documentation.</p>
  
  <p>I have also set up a single page for my search results with the code from the Documentation as well:</p>
  
  <pre><code>&lt;h1&gt;Search Results&lt;/h1&gt;
  {% set query = craft.request.getParam('q') %}
  {% set entries = craft.entries.search(query).order('score') %}
  {% if entries|length %}
  &lt;p&gt;{{ entries|length }} results:&lt;/p&gt;
  &lt;ul&gt;
      {% for entry in entries %}
          &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  {% else %}
  &lt;p&gt;Your search for “{{ query }}” didn’t return any results.&lt;/p&gt;
  {% endif %}
  </code></pre>
  
  <p>So, now if i try to search at the index page and hit enter, it just reloads the index page with the search term</p>
  
  <pre><code>site.url/index.php?q=test
  </code></pre>
  
  <p>So for sure i am missing a step here and am not loading the right page. I guess it should be stated in {{ url('search/results') }}, but i have no idea what to put there.</p>
  
  <p>Would be great if anybody could help me or at least point me to a tutorial that focuses on setting up a site search in Craft CMS.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-16T09:22:59.317Z
Comments.Text: In your code do you close the `<form>` as you aren't in your example
Comments.UserDisplayName: Justin Dekkers
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-16T10:16:00.047Z
Comments.Text: sure ;) it just got pushed to the next line and disappeared here, fixed that. thanks
Comments.UserDisplayName: Tobias Dax
Tags: <search>
Title: Can't get Frontend Search to work
ThreadText: # Can't get Frontend Search to work
  
  (Asked by: username_0 on 2017-03-16)
  
  Well, to be honest i am completely new, not only to Craft but to most PHP stuff as well.
  I am currently trying to setup a search for my page but i seem to miss a crucial step and can not find any tutorials on what to do.
  
  On my front/ index page i included
  
  ```
  <form action="{{ url('search/results') }}">
  <input type="search" name="q" placeholder="Search">
  <input type="submit" value="Go">
  </form>
  
  ```
  
  as stated in the Craft Documentation.
  
  I have also set up a single page for my search results with the code from the Documentation as well:
  
  ```
  <h1>Search Results</h1>
  {% set query = craft.request.getParam('q') %}
  {% set entries = craft.entries.search(query).order('score') %}
  {% if entries|length %}
  <p>{{ entries|length }} results:</p>
  <ul>
      {% for entry in entries %}
          <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
      {% endfor %}
  </ul>
  {% else %}
  <p>Your search for “{{ query }}” didn’t return any results.</p>
  {% endif %}
  
  ```
  
  So, now if i try to search at the index page and hit enter, it just reloads the index page with the search term
  
  ```
  site.url/index.php?q=test
  
  ```
  
  So for sure i am missing a step here and am not loading the right page. I guess it should be stated in {{ url('search/results') }}, but i have no idea what to put there.
  
  Would be great if anybody could help me or at least point me to a tutorial that focuses on setting up a site search in Craft CMS.
  
  **Tags:** search
  
  > **Comments:**
  > **username_1**: In your code do you close the `<form>` as you aren't in your example  
  > **username_0**: sure ;) it just got pushed to the next line and disappeared here, fixed that. thanks  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-03-16. Score: 1 | Accepted answer
  
  Inside of the `<form action="{{ url('search/results') }}">` You define which page should be redirected to when the search form is submitted.
  
  "search/results" would go to the search folder looking for the results.(html / twig).
  
  If you want to redirect to another page you should name the folder (which is "search" now) then the template name. This can be static without creating a "Single" for that page.
  
  If you did create a single that uses that template and you want to go through your single you can just put the slug of the created Single inside your form action.
  
  **Example:**
  
  You made a folder in craft/templates/ named: search, inside that folder you make a file named: results.
  
  So the file structure would be craft/templates/search/results.twig and the form action would be: `<form action="{{ url('search/results') }}">`
  
  This way you can just use the preset search template the craft docs offer you. You could also change "results.twig/html" to index.html and then your form action wouldn't need the /results so your action would look like:
  `<form action="{{ url('search') }}">`
  
  But I see you get redirect to /index.php/ aswell so I should try rmeoving that by changing your `.htaccess` file and maybe your general.php.
  
  You can find instructions on how to do that here:
  <https://craftcms.com/support/remove-index.php>
  
  
  ---
  
  