Adrian Cini

Adrian Cini - Web Developer and internet marketer personal blog

Implement a CMS site using MVC with inbuilt SEO functionality

In this short article you will gain an interesting approach on how to best create a basic CMS (Content Management System) in MVC (Model View Controller) that covers some SEO (Search engine optimisation) Basic requirements.

Before you continue you need to be familiar with the concepts mentioned above and have a sound knowledge of

  • C# language
  • MVC .Net Framework
  • SQL Database server
  • Entity Framework
  • The need for SEO

Most of the architectures for a Content managed website is made up of an MVC web application that connects to a database used to store your content. I am using a Windows hosting with MS Sql server but this example can be applied to any other technology Stack.

Diagram showing Client Site, Admin Site connected to a Data Layer [edmx] and database

When we create a table in the Database to store the articles we will think for both content and SEO. For the content I will need:

  • ArticleId -> primary key to identify the article
  • Summary -> A short description of the article used for those read more samples
  • FullArticle -> To store the HTML with the full article
  • As I will be using this table to store page articles and sub articles this can be achieved by Section and Category. For example Section: Home and Category : MainArticle would identify this article as the main article in the home page.
  • Section -> Page name
  • Category -> MainArticle, Sub Article
  • Position -> In case of multiple articles in the same page we can use this for ordering purposes
  • AppId -> This will identify to which Application the article belongs as I have one CMS for several sites

For SEO I will need some further data:

  • Title - We will use this to tag the page title. Ideally we have a title that describes the page in 40 characters.
  • Publishdate - We can use this to put articles in non published state
  • MetaTags - Meta tags ara comma separated text that will describe your article.
  • UpdateDate - This date will be used in the sitemap and part of the article meta information
  • AuthorId - Google plus AuthorId. This will be used to associate the article to the author profile and even display the author image in the search engine result. To get the author Id load your google plus profile and look for the OID Html tag in the source example oid="111254170622220751214"
  • SeoIndex - I will use this flag to exclude the article from having it SEOIndexed. This is used mainly if the article will appear more than once as google does not like indexing repeated content.

The sql for this table final table will look like the one below: Sql script for article table

Loading The Data

I suggest to create a new class library in the project which will take care of reading and writing data. Having the process done through a Class Library will allow us to reuse this logic in the Web site and the Content Management Site. In the Class Library we will create a DataEntity that will map entities to the database for reading and storing data.

As this data needs to be retrieved very fast we will create a class that returns all the Articles using some server caching so that we save on database hits and have the application run faster as this is an other SEO critical success factor. The in-memory object cache (System.Web.Caching.Cache) is used to store commonly used expensive data on server side and the code below shows how you can easily achieve this.

GetAllArticles code

Using The Data

We will add the meta data tags and the page title in the MVC master page this is normally located in the Views/Shared/_Layout.cshtml by making use of dynamic variables in the page Header.

page layout header

In the HomeController create a method to call the get articles for that particular page.

Home controller index method

The SetMetaTag method will create the meta tags to be replaced by the tags we just created in the Layout Page. We will be creating 2 types of meta tags. The typical HTML5 meta tag that is used to provide data about the HTML document and the og:tag also known as the open graph tag. These type of tags are used by social applications like facebook, twitter and google search engine to interpret the information in your page.

internal void SetMetaTag

The Full Article

In my page design. I will be using the Section and category fields to create pages. A page will be made up of Category for example "Home" and different subCategories example mainSection, SubArticle. In this way I can control the whole page from one cms and treat all the parts of this page as different articles. My basic page view would look something like this:

This is the main article

Main article section

These are the sub articles displayed as summary with the read more option

Sub article view

For the read more option I am using url rewriting so that I can provide a human friendly url. This way I can use the title field define in the table for the article as the url name and trick google and readers into believing that this is the actual page file name. Where in truth I will be using the article Id to load the article into a standard page.

Url routing is a cool feature of MVC and it can be easily controlled from the class Global.ascx.cs. In the Application_Start section look for the class that registers routes. In the the RegisterRoutes class I will add a Map route for the full article so that I can pass the full article title as the name but point it to the same controller.

register routes

In this case I am using the HomceController FullArticle method to route any FullArticle url.Example ../../FullArticle/18/How this site works Will be rerouted to the full article method that will render the article by loading the data using the article id which is passed in the url as if it was just a folder for the page.

Full Article view

In the full article view I will make use of the AuthorId if present to associate the article to the author and display his image.

Including the author id

About the author

Adrian Cini - worked in different markets like gaming , marketing, regulatory bodies, government etc. Passionate in Internet marketing, search engine optimisation and development frameworks.
Facebook

Comments (39) -

  • www.newasiainconline.com

    1/17/2014 2:29:43 AM | Reply

    I constantly spent my half an hour to read this website's articles everyday along with a cup of coffee.|

  • Water Conditioner Installation

    1/31/2014 12:52:47 PM | Reply

    I really love your site.. Excellent colors & theme. Did you make this amazing site yourself? Please reply back as I'm attempting to create my very own site and want to learn where you got this from or what the theme is called. Appreciate it!|

  • Vannesa

    2/5/2014 10:43:41 PM | Reply

    Thanks for your imput, hope to read more from you good job.

  • brazil vs france 2006 world cup

    2/6/2014 7:04:02 AM | Reply

    Hello there; I've been coming by your site quite often & have been asking myself if it's possible to subscribe to your articles other than via a RSS feed. I noticed that many weblogs offer E-Mail subscriptions for their latest posts. Do you offer that for your blog as well by any chance? Thanks for any advice. Krystina Akimseu from London

  • jewels

    2/22/2014 9:28:56 PM | Reply

    Great contribution love your blog, hopefully I'll be back.

  • crystal

    2/23/2014 8:56:55 AM | Reply

    There are so numerous blog sites online, I'm grateful I discovered yours today, keep it up.

  • my story

    2/27/2014 7:07:27 PM | Reply

    I just could not leave your website prior to suggesting that I actually loved the usual information an individual supply in your guests? Is going to be again regularly to inspect new posts.

  • Viviana

    3/1/2014 4:14:57 AM | Reply

    Keep the helpful post coming, I have been able to get what I needed from it.

  • Kit

    3/1/2014 5:49:37 PM | Reply

    I am sure everyone that has come to your website has appreciated it as much as me, keep up th good informative work.

  • tootpaste

    3/22/2014 1:05:05 PM | Reply

    Thanks for making my look for information worth while

  • how to maintain an erection during intercourse

    3/23/2014 11:29:14 PM | Reply

    whoah this blog is fantastic i love reading your posts. Keep up the good work! You know, a lot of people are searching around for this information, you can help them greatly.

  • click

    4/2/2014 6:03:37 PM | Reply

    Great, thanks for sharing this post.

  • Brian

    4/10/2014 8:07:26 AM | Reply

    Very nice, thanks for the post.

  • on bing

    4/18/2014 4:34:40 PM | Reply

    I always was concerned in this subject and still am, appreciate it for posting.

  • Ludivina

    5/5/2014 12:57:58 AM | Reply

    I think this is among the most vital information for me. And i'm glad reading your article. But should remark on few general things, The web site style is perfect, the articles is really excellent : D. Good job, cheers|

  • (aquaponics|hydroponics|aquaponic|hydroponic|aquaponics system|hydroponics system|aquaculture|grow lights)

    5/10/2014 8:10:49 AM | Reply

    Hey there! Appreciation for the superb advice! It certainly helped me quite a bit. Feel free to drop by and see my blogging site which is about aquaponics!

  • chat

    5/22/2014 1:45:55 PM | Reply

    Its  fantastic  as your other  content  : D,  appreciate it for posting . "Say not, 'I have found the truth,' but rather, 'I have found a truth.'" by Kahlil Gibran.

  • Boxes Printing

    5/23/2014 5:13:36 AM | Reply

    A person essentially help to make severely articles I'd state. That is the first time I frequented your web page and thus far? I amazed with the analysis you made to create this particular post incredible. Excellent process!|

  • Zula

    5/24/2014 11:58:02 PM | Reply

    Greetings I am so happy I found your blog, I really found you by error, while I was looking on Digg for something else, Nonetheless I am here now and would just like to say many thanks for a incredible post and a all round entertaining blog (I also love the theme/design), I don�t have time to browse it all at the minute but I have book-marked it and also added in your RSS feeds, so when I have time I will be back to read more, Please do keep up the awesome b.|

  • Yolanda

    5/25/2014 1:55:28 PM | Reply

    hey there and thank you for your info � I have definitely picked up anything new from right here. I did however expertise some technical issues using this website, since I experienced to reload the site a lot of times previous to I could get it to load correctly. I had been wondering if your web host is OK? Not that I'm complaining, but sluggish loading instances times will very frequently affect your placement in google and could damage your high-quality score if ads and marketing with Adwords. Anyway I'm adding this RSS to my e-mail and can look out for a lot more of your respective interesting content. Make sure you update this again very soon.|

  • uk agents

    6/3/2014 11:27:06 AM | Reply

    I was trying to find something beneficial to check out, thanks for sharing

  • snipping tool

    6/15/2014 7:05:54 AM | Reply

    This was an incredible read. Thank you for sharing it with us! Nowadays the web is full of poor content but there is no doubt that you spent much time by editing the information. Again, we appreciate you your time as well as your efforts!

  • best massage chair

    9/16/2014 9:19:00 AM | Reply

    It's an remarkable article designed for all the web users; they will take advantage from it I am sure.|

  • fryzjer warszawa

    10/8/2014 8:52:39 AM | Reply

    Great blog! i love it Smile !

  • Jacinda Sands

    10/29/2014 3:48:37 AM | Reply

    Way cool! Some very valid points! I appreciate you writing this write-up plus the rest of the site is also very good.

  • Valeria Goldhirsh

    10/29/2014 11:28:55 PM | Reply

    I'm very pleased to discover this great site. I wanted to thank you for your time for this particularly fantastic read!! I definitely enjoyed every little bit of it and i also have you bookmarked to look at new things in your website.

  • Cyrstal Russman

    10/30/2014 1:37:50 AM | Reply

    I was able to find good information from your content.

  • Matthew C. Kriner

    12/1/2014 7:55:19 AM | Reply

    I do not even know how I ended up here, but I thought this post was great. I do not know who you are but definitely you're going to a famous blogger if you aren't already ;) Cheers!

  • ������������ � ������� ������

    12/12/2014 3:07:10 AM | Reply

    Hey, thanks for the post.Really looking forward to read more. Want more.

  • Marisha Amlin

    12/15/2014 4:10:09 PM | Reply

    Hi there! Do you use Twitter? I'd like to follow you if that would be ok. I'm absolutely enjoying your blog and look forward to new updates.

  • Vicky Gitto

    12/18/2014 7:36:06 PM | Reply

    I'm curious to find out what blog platform you're working with? I'm having some small security issues with my latest blog and I would like to find something more safe. Do you have any solutions?

  • factores que influyen en el posicionamiento seo

    12/19/2014 5:13:40 AM | Reply

    Buen�simo!!!!!!. Bien hecho, me encanta el art�culo. Gracias por compartir.

  • Personalized Santa Calls

    12/20/2014 12:33:00 AM | Reply

    With havin so much written content do you ever run into any issues of plagorism or copyright infringement? My website has a lot of completely unique content I've either created myself or outsourced but it appears a lot of it is popping it up all over the web without my authorization. Do you know any methods to help stop content from being ripped off? I'd genuinely appreciate it.

  • analisis seo pagina web

    12/20/2014 3:10:49 AM | Reply

    Excelente comentario y sobre todo �til. Es lo que estaba buscando. Gracias

  • ecommerce

    12/22/2014 12:18:32 AM | Reply

    Buen�simo!!!!!!. Bien hecho, me encanta el art�culo. Gracias por compartir.

  • this girl

    12/23/2014 5:30:17 AM | Reply

    Just  a smiling visitor  here to share the love (:, btw  outstanding  design and style .

  • see page

    1/8/2015 8:54:57 AM | Reply

    I have been absent for a while, but now I remember why I used to love this website. Thanks, I will try and check back more frequently. How frequently you update your website?

  • Walter

    5/15/2015 12:00:37 PM | Reply

    I am trying to learn ASP.NET MVC and your article looks very informative. Thank you. Would you please email me the code download that I could run and learn from. Thanks.

Loading