diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml
index 7f89bdf0e9a..4eed58e2638 100644
--- a/app/views/layouts/_head_panel.html.haml
+++ b/app/views/layouts/_head_panel.html.haml
@@ -8,9 +8,7 @@
GITLAB
%span.separator
%h1.project_name= title
- .search
- = form_tag search_path, method: :get do |f|
- = text_field_tag "search", nil, placeholder: "Search", class: "search-input"
+ = render "layouts/search"
.fbtn
- if current_user.is_admin?
= link_to admin_root_path, class: "btn small", title: "Admin area" do
@@ -29,11 +27,3 @@
= link_to 'Logout', destroy_user_session_path, class: "logout", method: :delete
= render "layouts/init_auto_complete"
-
-:javascript
- $(function(){
- $("#search").autocomplete({
- source: #{raw search_autocomplete_source},
- select: function(event, ui) { location.href = ui.item.url }
- });
- });
diff --git a/app/views/layouts/_search.html.haml b/app/views/layouts/_search.html.haml
new file mode 100644
index 00000000000..80ecc5304d6
--- /dev/null
+++ b/app/views/layouts/_search.html.haml
@@ -0,0 +1,11 @@
+.search
+ = form_tag search_path, method: :get do |f|
+ = text_field_tag "search", nil, placeholder: "Search", class: "search-input"
+
+:javascript
+ $(function(){
+ $("#search").autocomplete({
+ source: #{raw search_autocomplete_source},
+ select: function(event, ui) { location.href = ui.item.url }
+ });
+ });