Pages

Saturday, April 2, 2016

Easy Way To Change Wiki Page Title In SharePoint 2013

Introduction

In this post, I will demonstrate easiest way to change the Wiki Page Title in SharePoint 2013.

I have shown the same in one of my last posts - here is the link to it.

The ways shown in my earlier post will work but I felt there is always a better way to do certain things, especially in programming world. :)

So, here I will show yet another but easy way to change the Wiki Page Title in SharePoint 2013.

Prerequisites

Here, the prerequisite required is knowledge of JQuery!

Solution

There are only few steps to be followed. 

Step 1. - In your existing Wiki Page, just add Script Editor web part to your page.
To add the same, on your Wiki Page, click on "Site Setting" button on top right corner of your page and then click on "Edit Page" (as shown below). Here, my Wiki Page Title is "TestPage" and I will demonstrate on how to change it.



 Step 2. - Once you click on "Edit page", your page will be in edit mode. On top ribbon, click on "INSERT" tab and then click on "Embed Code" (as shown below).



Step 3. - As you click on "Embed Code" button, you will see  a pop up to insert a code (as shown below).


 Step 4. - In this multi line textbox, we will insert a following code:

  <script src="https://code.jquery.com/jquery-1.12.2.min.js" type="text/javascript"></script>
  <script type="text/javascript">
        $(document).ready(function () {
            changeWikiTitle("TestPage", "My Changed Title Page");
        }); 
        var changeWikiTitle = function (currentTitle, newTitle) {
            var allAnchorTags = $("a[title$='" + currentTitle + "']");
            $.each(allAnchorTags, function (i, v) {
                if ($(v).attr("title") == currentTitle) {
                    $(this).text(newTitle);
                    return false;
                }
            });
        }
    </script>

So, in the above code, you could see, on first line I am referencing JQuery library from CDN.

Under $(document).ready(); function, I am calling "changeWikiTitle" function.

This function accepts 2 parameters, one is your current Wiki Title and another parameter is the new Wiki Title you would like to provide to your Wiki Page.

Step 5. - Finally, make the changes to the parameters in "changeWikiTitle" function, copy the code and paste it to the multi line textbox of your script editor web part.

Once pasted, click on "Insert" button and then click on "Save" button on top ribbon of your SharePoint Wiki page and you will see your Wiki Page Title has been changed to the new Title (as shown below).



Conclusion

In the end, we came across yet another easy way to change the Wiki Page Title of our SharePoint Wiki Page. I hope it will help you!

No comments:

Post a Comment