Jump to content

[SOLVED] Adding a code block (or a google custom search engine) to the site header (7.1)

Go to solution Solved by tuanphan,

Recommended Posts

Since I haven't been able to get the search block to work, I decided to go with Google's "Programmable Search" and just paste the HTML to a code block. However, I'd like to have the search bar in the header instead of taking up space on every page. Any suggestions would be greatly appreciated. Thanks!

Edited by dl_23
Specify version
Link to comment
  • dl_23 changed the title to Adding a code block (or a google custom search engine) to the site header (7.1)
  • Solution
On 9/28/2021 at 9:26 PM, dl_23 said:

Exactly!

Add to Last Line in Code Injection > Footer

<script>
  $(document).ready(function() { 
		$('div#block-aada196faed00d4629aa').insertBefore('nav.header-nav-list');
	});
</script>
<style>
  .header-nav-wrapper {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
  div#block-aada196faed00d4629aa {
    flex-basis: 60%;
}
</style>

image.thumb.png.935c4423a5c3a76250bdfdb0cf33c60b.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
5 hours ago, tuanphan said:

Add to Last Line in Code Injection > Footer

<script>
  $(document).ready(function() { 
		$('div#block-aada196faed00d4629aa').insertBefore('nav.header-nav-list');
	});
</script>
<style>
  .header-nav-wrapper {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
  div#block-aada196faed00d4629aa {
    flex-basis: 60%;
}
</style>

image.thumb.png.935c4423a5c3a76250bdfdb0cf33c60b.png

 

This worked great, thanks! However, is there a way to control the width of the search bar so that it doesn't push the header navigation links to two rows?

 

Edited to add: Nevermind. Just changed flex-basis to 40% and it worked. Thanks so much again!

Edited by dl_23
Link to comment
  • dl_23 changed the title to [SOLVED] Adding a code block (or a google custom search engine) to the site header (7.1)

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.