This is a techy bit and I don't want to delve into the meaning of life, the universe and program syntax - so I will be (very) brief.
These statements may look a bit odd but this is due to the order in which CMSMS processes page data. Plus, Smarty syntax is more compact than raw PHP code.
Each page variable is set from either itself (if it has already been set elsewhere in the page) or a default value (which may be another variable or it may be an outcome of another tag).
Lines 2 & 3: CMSMS has 2 fields that can be used as page title (description and title). If the description field is empty (it is optional), it defaults to the title field which is a compulsory page field.
Line 4: If that new additional content block mentioned above has nothing in it, then the first 300 characters of the main content is used, stripped of any markup.
Put this snippet into the Metadata field on the Logic tab in Edit Content screen for each of your pages that you want to be indexed by search engines.
Most of your existing pages will want to be indexed by search engines and so should have this meta tag set up. If you have only got a few pages, then you can just paste the snippet into the Metadata field on the Logic tab.
If you have got lots of pages in existence and they need this meta tag, then you could insert it into the appropriate place in your page template. If you are using template inheritance, the obvious place is the master page layout template.
Tip: put this snippet in the Metadata field on the New Page Defaults tab on Settings - Content Manager screen. So any new pages created thereafter will automatically have this snippet applied.
Note:The contents of page-specific Metadata fields will only be included in a rendered page if this tag
If a page is not to be indexed, then don't insert the meta description tag. Such pages could be your contact page, article summary pages, privacy/terms/cookies page. Use the following tag instead:
We set a page variable in step 2 above for this tag
cmsms-meta-tags. This can be used with or without another page variable
CCBS Web Services, depending upon your design preference.
Here are 2 title tag options - just put one of them in the head section of your page template.
This is adds another content entry field on the Edit Content screen so that a suitable meta description can be provided for the page.
It is visible under the main content editing area. The contents are stored into a page variable.
The News detail template should already include 3 News variables that we can use for these tags - summary, content and title.
I suggest you put these lines near the top of your template, leaving the rest of template for the layout of the News item itself.
Line 1: sets a flag to indicate that a News item is being processed. This is used in the master page layout for the title tag.
Lines 2 & 3: checks if the summary variable has anything in it. If so, the 1st 300 characters of the summary contents are used, after being stripped of markup and spaces, for the News meta description.
Line 5: if the summary variable is empty, the 1st 300 characters of the content variable is used instead, having the same adjustment made.
Line 7: the News title is stored for the News title tag.
This amends the code that we put in the master page layout in step 4 above.
As we are using the same master page layout for both page and News item, we test the News flag to see if a News item is being processed. If so, the title tag is set up from the News item title.
Store the above code in a Core::Generic template in Design Manager. I call my template generic-meta-article.
Why am I storing it like this and not putting it directly into the Metadata field on the Logic tab of the News page?
Because I can then add other meta tags for the News item, like the Open Graph types for Facebook. This is covered in one of my other CMSMS articles, link to this is in Additional Information below.
With the meta description tag stored in a Core::Generic template called generic-meta-article, put the following tag into the Metadata field on the Logic tab of the page that is used for News detail.
If your News page is dual-purpose i.e. it is used for News summary as well as News detail, then use this code instead.
The News flag is checked to see if a News item is being processed. If so, the News meta description, together with any other News item meta tags, is used. Otherwise, the page meta description tag is used.
If you don't want your News summary page to be indexed, then replace line 4 with: