Jump to content

Change Titles on Blog Category Pages

Recommended Posts

Site URL: https://www.bycourtneytodd.com/

Hi! Can someone help me figure out how to have different titles or headers at the top of my linked category pages? I've sorted my blog posts into categories and have linked buttons to a particular category but when I go to the category pages they all say "On The Blog" at the top and I want them to be titled based on the category.

I know I can create a page and add text box then a summary blog underneath, but not all my blog categories will have their own page so I'm hoping to find a work around to have each blog category link to a page with a title of the same name (e.g. when someone clicks on the blog category "recipe" the linked page should say "recipe" at the top, and when they click "Canadian Travels" the linked page should say "Canadian Travels" at the top, etc.)

Any help is very appreciated!

 

 

Screen Shot 2021-04-05 at 8.13.42 PM.png

Link to comment
  • Replies 7
  • Views 1.2k
  • Created
  • Last Reply

Add t

On 4/6/2021 at 7:19 AM, thenookcreative said:

Site URL: https://www.bycourtneytodd.com/

Hi! Can someone help me figure out how to have different titles or headers at the top of my linked category pages? I've sorted my blog posts into categories and have linked buttons to a particular category but when I go to the category pages they all say "On The Blog" at the top and I want them to be titled based on the category.

I know I can create a page and add text box then a summary blog underneath, but not all my blog categories will have their own page so I'm hoping to find a work around to have each blog category link to a page with a title of the same name (e.g. when someone clicks on the blog category "recipe" the linked page should say "recipe" at the top, and when they click "Canadian Travels" the linked page should say "Canadian Travels" at the top, etc.)

Any help is very appreciated!

Add this to Settings > Advanced > Code Injection > Header. Do similar for other category pages

<script>
  if (window.location.pathname == "/blog/category/Canada+Travels") {
    document.querySelector('body').classList.add('canada-travels');
  }
</script>
<style>
  .canada-travels section.Intro h2 {
    visibility: hidden;
}
  .canada-travels section.Intro h2:before {
    content: "Canada Travels Blog";
    visibility: visible;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
</style>
  

image.thumb.png.f18015060577b06ede2d0dd75b25e8fc.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

Replace the scrript tag with the following.

<script>

  window.addEventListener ( 'DOMContentLoaded', ( ) => {
  
    if ( location.pathname == '/blog/category/Canada+Travels' ) {
    
      document.querySelector ( 'body' ).classList.add ( 'canada-travels' );
      
      }
      
    } );
    
  </script>

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.