Well, to create a custom template in SharePoint 2013 or in Office 365 SharePoint, then it’s a very tricky task to complete. The thing very complex with web template is that, it ok up to publishing feature is not enabled in the Template site. But when the publishing feature is activated the that feature automatically gone from SharePoint web site.
Now, there is trick for that, to add that feature again in Site Settings, juts open that sit in SharePoint designer 2013 and activate/make it true. As this property sets to true the link for “Save as site template” will available.
Now, when we save that site template from(Publishing site) then it will have base template be PUBLISHING. So, now we have to add theme to it and also set our custom master etc. They are all be done in the Onet.xml which is get when we export that WSP in visual Studio export wizard template.