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

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

Edited by tuanphan
typo

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
On 4/13/2021 at 7:48 AM, thenookcreative said:

Thank you for your help! I added the code like you said but nothing changed.

can you keep the code in Code Injection? We can check easier

image.thumb.png.0ac950d1f9597f8e29e8f2d897eb4450.png

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

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

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.