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,240Questions: 1Answers: 2,599

    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: 63,678Questions: 1Answers: 10,498 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: 63,678Questions: 1Answers: 10,498 Site admin

    Nice workaround. Thanks for sharing it.

    Allan

  • paraplanioparaplanio Posts: 2Questions: 0Answers: 0

    Anyway to do this in DataTables v2? In this version no a href link, divs insted

  • allanallan Posts: 63,678Questions: 1Answers: 10,498 Site admin

    divs insted

    No it uses button for the pagination buttons, which is semantically correct.

    Why would you want to add an href attribute to the buttons?

    Allan

  • paraplanioparaplanio Posts: 2Questions: 0Answers: 0

    Yes, button, sorry.

    I need a[href] to save page filter/pagination history.

    For ex: switch to page 8, reload page and page 8 loaded again automatically.

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    You can use stateSave for this.

    Kevin

Sign In or Register to comment.