I’ve found a few semi-related articles on how to add meta-tags to the head (without changing the definition of the page I believe). I need to do this in a couple different ways… first of all I need to add some static global meta-tags (so does everyone actually), such as the website-spark tag, but also Google Analytics, Yahoo verification and probably Bing as well. Secondly is being able to add non-global meta-tags to the head; i.e. page specific (not site-wide) description and keyword tags (and any other meta-tags I may want to add on a page by page basis). There are multiple developers who have different .wsp solution packages to do so… I'm just not sure which would be best practice, and also was wondering exactly how the implementation of these solutions would differ from on-premise to online SharePoint. Here are some of the solutions I’ve found.

Using the delegate control to add meta-tags to SharePoint

Easy editing meta-tags publishing pages mavention meta-fields

It seems like I should be able to do something as simple as add Microsoft’s own meta-tag without unghosting the MasterPage… I don’t want to add another call to the server.




2 Answers 2


You can use ScriptBlock attribute to add custom javascript using a CustomAaction.


Notice ~site token inside ScriptBlock. It will be replaced with the server relative url of the current site (SPWeb). Another available token is ~sitecollection, which gives server relative url of current site collection (SPSite). It is useful, if you are deploying your feature to site scope. See example below:

      document.write('&lt;script type=&quot;text/javascript&quot; src=&quot;~site/JavascriptReferenceTestAssets/Test.js&quot;&gt;&lt;/' + 'script&gt;');"
    Sequence="100" />

You can apply the same approach for CSS and other Metatags

See more examples: http://simonovens.wordpress.com/2011/11/14/sandbox-sharepoint-online-jquery-jquery-ui-wsp-package/

  • I'm using this method in a sandbox solution and it works great. The only problem I've found so far is that it doesn't check if the script file has already been registered before loading it. For example, if you add jquery-1.7.2.js this way in two seperate web part projects and add both web parts to the same page, then you will get 2x copies of jquery-1.7.2.js being sent to the browser. Do you know of any way to prevent this? I tried prefixing document.write(...) with if(!jQuery) but the custom action appears to get processed BEFORE the scripts have actally been loaded :/
    – user4545
    Commented Oct 19, 2012 at 11:01

This was a very effective solution: Programmatically add JS/CSS to pages. Full details here: http://www.devharbor.blogspot.co.il/2011/09/sharepoint-programmatically-add-jscss.html. And you don't touch the master page at all :)

  • Thanks, but if you look at the link in my comment to my question I've linked to the original version of that solution... I've gotten temporarly sidetracked from working on this problem, (I still need to do it however), my main question about that particular solution is wether it can be implemented in SharePoint Online (there are differences between online and on-premise) SharePoint Online is run on SharePoint Foundation Server and On-Premise is generally either the SharePoint Enterprise or Standard Edition. Basically SharePoint Online has limited access to the server components (actually none) Commented Jun 16, 2012 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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