I have a web part with a button pressing which creates a new subsite using C# code. It is a team site. Is it possible to define following in that site using code at the time of site creation?

<meta name="description" content="Something here">

I am doing this so when a use searches for e.g. "Something here" then this page is shown in results.

Or is there a better way to do this?

Please note I have more than 500 such subsites already created so it will greatly help if you can give solution that will not apply to new sites but also existing ones.

  • How do you create a subsite in C# code? server side code, client side code, by templateprovisioning?? Show us a snipped of code where you create the subsite. Maybe you can add a content editor webpart to the welcome page. In the content editor webpart you can add the html <meta name="description" content="Something here">.
    – Ola
    Commented Jan 6, 2017 at 9:26

1 Answer 1


What you are trying to do is add meta tags to the page. This should be done in a control on the master page. Another option would be to use the Site Property Bag. You can read/write values to the property bag when you provision the site and then either index the property bag or use a custom control to read the values and emit the values as META tags.

You can change the provisioning process to write the values to the property bag. Write a control for the master page that reads the values.

One last option that I use all the time would be to simply provision a hidden list in the site that contains the values. Search indexing will find these values. Then write a Display Template that returns the home page of the site when the list item is found. The benefit to this approach is no custom code and you can easily edit the values if necessary.

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.