I have search working on my local .dev site. It does not work on my live hosted site. There are no error messages; it just reloads the home page.

Here is the search code in my site template. The results code is below...

<li class="menu-item-search">
    <a href="search.html"><i class="fa fa-search"></i><i class="fa fa-times"></i></a>
    <form method="get" id="site-searchform" class="searchform" action="{{ url('search/results')}}">
        <input type="search" name="q" autocomplete="off" placeholder="Search&hellip;">
        <input type="submit" value="Go">

The results page...

<main id="content" class="cointainer container-masonry" role="main"> 
    <div id="grid-fix" class="container">

        {% if entries|length %}     
            {% for post in entries %}
                <div class="box col-sm-3">
                    <div class="post-box vertical clearfix">

                        <div class="extra-info">                
                            <h5><a href="{{ post.url }}">{{ post.title}}</a></h5>
                            <p class="meta small">{{ post.postDate | date('F d, Y') }} <a href="#">Name</a></p> 
            {% endfor %}    
        {% else %}
            <p>You search for "{{ query }}" didn't retun any results</p>
        {% endif %}

Any thoughts? Thanks.

  • You're not getting sent to yoursite.com/search/results? – Brad Bell Nov 23 '16 at 20:07
  • The problem appears to be with the "{{ url('search/results') }}". I can hard code it as "mysite.com/search/results" and it works. For some reason, Craft/Twig is not printing the first part of the url. – Hellyar Nov 23 '16 at 20:49
  • Probably an issue with how your siteUrl is defined (either in CP under Settings->General) or in your craft/config/general.php file. – Brad Bell Nov 23 '16 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.