I have a wiki page library where I would like to create a template that dynamically displays metadata related to that page. for instance:

created by created on modified by modified on category

Is there a way to dynamically bring in metadata to the page.aspx?


You can use the following code to display the metadata of the current page.

Note: change the internal field names in the scripts to yours.

<div id="displayDiv"></div>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
var pageName = window.location.pathname.split("/").pop();
var libraryName = "wikis";
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('"+libraryName+"')/items?$select=Author/Title,Editor/Title,OData__Category,Wiki_x0020_Page_x0020_Categories&$expand=Author/ID,Editor/ID&$filter=FileLeafRef eq '"+pageName+"'";
var requestHeaders = { "accept" : "application/json;odata=verbose" };
    url : requestUri,
    contentType : "application/json;odata=verbose",
    headers : requestHeaders,
    success : onSuccess,
    error : onError

function onSuccess(data, request){
        var page=data.d.results[0];
        var author = page.Author.Title;
        var editor = page.Editor.Title;
        //single text
        var category = page.OData__Category;

        //Get Multiple Taxonomy Field value
        var categories="";
        var tags = page.Wiki_x0020_Page_x0020_Categories.results;
            for(var i = 0; i < tags.length ; i++) {
                var tagLabel = tags[i].Label

        var content = "<b>Create By: </b>"+author+";</p><b>Modified By: </b>"+editor+";</p><b>Category: </b>"+category+"</p><b>Categories: </b>" +categories;

function onError(error) {

If you want to make it as the template, so that you don't need to enter code in each page manually, you need to use a page layout content type such as Enterprise Wiki content type in the library and create and design a custom page layout. Create new page based on the custom page layout.

How to create a page layout

How to display page metadata in the page layout

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.