Episode 9 is Live!!
The latest installment of my Learning by Doing: Build Series on Optimizely Episode 9CMS 12 is now available on YouTube!
This video focuses on integrating Search Engine Optimization (SEO) fields into a custom Content Management System (CMS) website.
Key Takeaways:
Extending the Page Model:
- The existing SitePageData base model was extended to add a new property, MetaKeywords, which is a list of strings, utilizing a PropertyStringList backing type.
- The existing MetaTitle and MetaDescription fields were also organized.
Integrating with the Layout File:
The common _Layout.html file was updated to dynamically render the SEO data within the <head> section of the HTML.
Dynamic Meta Tags:
- The <title> tag now pulls data from Model.MetaTitle.
- A meta tag for description was added, using a conditional check (if (!string.IsNullOrEmpty(...))) to ensure it only renders if content is present.
- A meta tag for keywords was added, using @String.Join(", ", Model.MetaKeywords) to format the list of strings into a comma-separated list, also protected by a conditional check.
Testing and Verification:
Changes were published in the CMS interface, and inspecting the live website's source code confirmed that the meta tags were correctly implemented.
Introducing a Hero Block:
The episode concluded by beginning work on a new "Hero Block" model and view model to add a prominent visual component to the homepage.
.png)
Comments
Post a Comment