In this article we are going to integrate a simple blog template to our application. You can download the a free bootstrap template that I'm using for this tutorial in startbootstrap.com. For this tutorial, two templates are going to be referred for blog home and blog post.
Step 01: Extract the downloaded files into a folder
You should be able to see following folders and files as shown below.
Step 02: Let's Create a View for master layout in Umbrao Portal.
Login to you UmbracoCMS back-office as an Administrator. If you have followed my previous article the default url of the back-office would be http://localhost/UmbracoDemoApp/umbraco
Go to Settings --> Templates --> Create --> Name the template as Master --> Save
Let's move to the Visual Studio to set up the rest of the things in the application. To view the created Master template, click show all files then include the Master.cshtml.
Step 03: Copy HTML code from the template
- Open the "startbootstrap-blog-home-gh-pages" folder.
- Open the "index.html" page in notepad and copy the whole content.
- Paste the content inside Master.cshtml (Do not overwrite the existing content in the Master template)
There are 4 areas in the template. In future, we will separate those areas into Partial Views.
- head
- body content (dynamic content area)
- side bar
- footer
Let's move vendor and css folder to the Visual studio solution from the downloaded template. Make sure you prefix all src and href properties of style-sheets and Js in the Master template file with "~/".
Note: No need to prefix src and href which have "#" or "".
You are almost done with integrating the template to the demo app. Let's create another Home template under master template.
Step 04: Create a Document Type "Home"
Go to the Umbrao back-office and navigate to the Content Type node. Create Home and Choose the template as Home as shown below.
Step 05: Create a Home Page
Navigate to the Content Node and Create home page. Make sure the template is set to Home and click "Save and publish".
That's it. Give a hit to http://localhost/UmbracoDemoApp/ to view the integrated template in UmbracoDemoApp. In the next article will see how to create partial views for the header, footer, and sidebar. Refer Create a Master Template(layout) in Umbraco CMS part 2 for more details.
Thank you for sharing this informative post. Looking forward to reading more.
ReplyDeleteBest Web Design Company