Adding href parameter for the pagination links

Adding href parameter for the pagination links

Saravanan_DharmarajSaravanan_Dharmaraj Posts: 3Questions: 1Answers: 0

Link to test case: https://www.silabs.com/support/resources.ct-data-sheets.page=2
Description of problem: We are using DataTable with pagination as given in the URL above. During our Google SEO analysis we found the pagination links are missing href pointing to a page and google cant crawl the pages going into the pagination links. So the google search is not indexing/serving the pages/documents in their search results from those pagination links.
Could anyone please advice on how to add href to the pagination links since its auto generated by the plugin instead of like
<a class="paginate_button " aria-controls="DataTables_Table_0" data-dt-idx="1" tabindex="0">1</a>. Any help is appreciated. Thanks

Answers

  • colincolin Posts: 15,154Questions: 1Answers: 2,587

    I just looked at the link and the href is present - has this been resolved or am I missing something?

    Colin

  • Saravanan_DharmarajSaravanan_Dharmaraj Posts: 3Questions: 1Answers: 0

    Hi Colin,
    I am talking about Pagination anchor tags. It doesn't have href in it which is causing the google to ignore it while indexing.

  • allanallan Posts: 61,771Questions: 1Answers: 10,112 Site admin

    At this time you can't. We are going to change them to be buttons in future rather than link tags.

    Allan

  • Saravanan_DharmarajSaravanan_Dharmaraj Posts: 3Questions: 1Answers: 0
    edited May 2022

    I actually added the href through the drawCallback method like this

    "drawCallback": function( settings ) {
                        var currentURL = window.location.pathname;
                        var pageEle = $('a.paginate_button');
                        $(pageEle).each(function(){
                            var pageNum = parseInt($(this).text());
                            if(!(Number.isNaN(pageNum))){
                                var pageurl = currentURL+".page="+pageNum;
                                $(this).attr("href",pageurl);
                            }
                        });
                        $("a.paginate_button").on("click", function(e){
                            e.preventDefault();
                        });
                    }
    
  • allanallan Posts: 61,771Questions: 1Answers: 10,112 Site admin

    Nice workaround. Thanks for sharing it.

    Allan

Sign In or Register to comment.