Problems with Enterprise Wiki Page TitlesCreate a new page called "My New Page" in an existing page by enclosing that title in double square brackets:
Problem #1: Spaces in File NamesThe page title is used to create the page's name (i.e., file name), which will contain spaces (even though the form lies and tells us it will replaces spaces with hyphens). The spaces will often be encoded as %20, and this does not follow good URL conventions.
Problem #2: Changing URLsIf the page's author decides to edit the page's name, even if just slightly, it results in a different URL for the page. That is definitely not following web conventions of URLs not changing, and will lead to broken links for any place where you've added the full URL of the page manually as a link.
Problem #3: Unchanging Page TitleThe page's actual title attribute will stay whatever the page's initial name was (unless the author actually edits the page's properties). This is not unlike the problem in Office documents where we see and change the file name, often using one file as a template for many others, but the "title" remains the same (and therefore is wrong for all the copies).
Solution for Enterprise Wiki PagesThis solution involves two small code changes and a new Authoring habit.
Modify EnterpriseWiki.aspxI almost always recommend against changing any OOTB SharePoint files. But in this case, this can be done easily and does not risk breaking anything else or causing significant upgrade issues later.
Open the site in SharePoint Designer 2013, and open this file:
/_catalogs/masterpage/EnterpriseWiki.aspxNote: It is a good idea to make a copy of this file somewhere, even if it's just your desktop. You know, just in case.
- Find the content place holders with IDs PlaceHolderPageTitle and PlaceHolderPageTitleInTitleArea.
- Edit the SharePoint:ListItemProperty for both content place holders by adding a new property called Property with the value of Title.
- Next, find the SharePoint:FileField control with ID PageNameInEditMode
- Add the following code just below that line:
<b class="ewiki-pagename-align"><SharePoint:FieldLabel FieldName="Title" runat="server"/></b>It should look like this:
<SharePoint:TextField id="PageTitleInEditMode" DisableInputFieldLabel="true" FieldName="Title" runat="server"/>
- Save and close.
Edit Page Names When Authoring the Content
- Create wiki pages as normally done with the square bracket method. In our example, it is [[My New Page]].
- Save and view the page with the new link, and click on the dashed underline to create the new page. Ignore the URL it gives you on that page; it is still wrong.
- When editing the new page, modify the Page Name to conform to your URL naming conventions. You can use camel case (e.g., "MyNewPage") or convert spaces to hyphens (e.g., "My-New-Page").
- Save the new page.
Automatic Link UpdatesNow you have nicer URLs and Titles, but what about the links that reference this new page? These get updated automagically.
To test, go back to the page on which you created the link by adding it in square brackets. The link should now have no underline or a solid underline (depending on your site's CSS), indicating that the file does indeed exist. Click the link, and you should get to your new page. Then check the URL in the address field of your browser against the title on the tab and page.
Using Square Brackets for LinksYou can still use double square brackets for linking to your pages this way, but SharePoint uses the page name, not its title, for this. So to make links show nicely, get used to typing "[[My ", etc. to find your page, and then type a pipe (|) and the page title or other link text you want to display, then close your brackets "]]". Example:
"[[MyNewPage|My New Page]]"
One small quirk occurred in my original testing: The page's link from the Quicklaunch did work, but the actual URL of the link was different. Instead of:
[domainName]/sites/wiki/Pages/MyNewPage.aspxthe URL was:
[domainName]/sites/wiki/my-new-pageThis URL is the "term-driven" URL that exists when using Managed Navigation. The problem is that these don't seem to be automatically updated when you change the page's name. So if you used Managed Navigation, you will probably have to manually update your terms' URLs in the Term Store Management Tool for the site collection.
I hope this is helpful. I had been reluctant to use the Enterprise Wiki site collection template in SharePoint primarily because of the above problems. Now I expect to use them more. There are some other enterprise wiki features that would be nice (I used Atlassian Confluence for a while, and that was really nice and flexible), but this will work for now.