I'm working on SP2013 sites. in one webapp, self created site feature is on, users created some sites already. the urls are:


They changed their sites theme by using "Change the look' in menu.

Is there a way to change theme for all these sites for different accounts? or have to change them one by one?

I want to add a javascript code to all self created sites (their url is like: http://mydomain.com/my/domain_account ), how do I do it? the theme's master page url like:


which includes 'domain_account', do I have to add code to each master page one by one? or, there is a way so that all these master pages inhert from it?


1 Answer 1


Each MySite of a user is a site collection. One of the ways to update all of them is to use code in Console application or use PowerShell. You will need to loop through all site collections of a web application and check if the site collection is MySite and then change the theme and modify the master page of the site collection.

Code to check if a site is based on MySite template:

if (oWeb.WebTemplate == "SPSPERS")

Code to apply theme:

ThmxTheme theme = ThmxTheme.Open(oWeb.Site, "_catalogs/theme/" + themeName + ".thmx");
theme.ApplyTo(oWeb, true);


Feature stapling can be used to make changes to automatically created my sites. Two features are needed one that will do the actual work of applying the theme, master page etc and another feature which attaches the first feature to a specific site definition. In this case it is "SPSPERS#0". The second feature is called as feature stapler. An example looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Associate MySite.Master Feature-->
  <FeatureSiteTemplateAssociation Id="75C873F1-CE03-4A07-B3BB-75ACD661E8EC" TemplateName="SPSPERS#0" />
  • That's what I'm afraid of. So, it means when a new self serviced site created, we will have to manually make changes to keep it consistent with other self-serviced sites? is there a way to make them to inhert from mydoamin.com , the self-serviced site host?
    – urlreader
    Commented Feb 20, 2014 at 7:06
  • See my edits for more information. Commented Feb 20, 2014 at 8:14

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.