Jump to content

Add a link above individual blog post title

Recommended Posts

I am trying to make the text "Notes, Queries and Explanations" at the top of the individual blog posts a link back to the home blog page.

The text is currently added using the content attribute and am having trouble working out the javascript. What can I do to make that a link? 

Link to comment
  • Replies 2
  • Views 395
  • Created
  • Last Reply

Add the following to Blog Settings > Advanced > Page Header Code Injection for the blog page.

<script>

  $( ( ) => {
  
    /*
    
      begin add linked text to blog title
      
      SS Version : 7.0
      Template   : Brine family
      
      */
      
      const text = 'NOTES, QUERIES AND EXPLANATIONS';
      
      const url = '/notes-queries-and-explanations';
      
      // do not change anything below, there be the borg here
      
      $( '<a>' +
      
        text +
        
        '</a>' )
        
        .attr ( 'href', url )
        
        .prependTo ( '.BlogItem-title' );
        
      // end add linked text to blog title
      
    } );
    
  </script>

This is for a v7.0 site using the Brine template family.

You can retarget your CSS from .BlogItem-title:before to .BlogItem-title a and make the minor adjustments needed.

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
16 hours ago, creedon said:

Add the following to Blog Settings > Advanced > Page Header Code Injection for the blog page.


<script>

  $( ( ) => {
  
    /*
    
      begin add linked text to blog title
      
      SS Version : 7.0
      Template   : Brine family
      
      */
      
      const text = 'NOTES, QUERIES AND EXPLANATIONS';
      
      const url = '/notes-queries-and-explanations';
      
      // do not change anything below, there be the borg here
      
      $( '<a>' +
      
        text +
        
        '</a>' )
        
        .attr ( 'href', url )
        
        .prependTo ( '.BlogItem-title' );
        
      // end add linked text to blog title
      
    } );
    
  </script>

This is for a v7.0 site using the Brine template family.

You can retarget your CSS from .BlogItem-title:before to .BlogItem-title a and make the minor adjustments needed.

Let us know how it goes.

Thanks! That did the trick!

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.