Where does the MetaTags <Title> and <Description> gets Written to for Non pages/posts?

Aug 18, 2011 at 3:20 AM
Edited Oct 24, 2011 at 8:29 PM

Hello all,

Trying to figure out what file writes the meta tags:

<meta name="description" content="Short description of the blog" />
<title>Name of the blog | Music</title>

For the following pages:

Category

Author List

Date

Tags

 

Like:

 

http://dev2.kbdavis07.info/category/BlogEngineNET.aspx   <--- what files injects the html tags?

http://dev2.kbdavis07.info/author/Admin.aspx

http://dev2.kbdavis07.info/2011/default.aspx

http://dev2.kbdavis07.info/2011/06/default.aspx

http://dev2.kbdavis07.info/?tag=/blog

<meta name="description" content="Short description of the blog" />
<title>Name of the blog | Music</title>

 

Since there is no category page its just virtual.

Thanks,

 

Brian Davis


Java Blog

Coordinator
Aug 18, 2011 at 9:11 AM

It looks like the keywords & description are set at the same place for Category pages, Tag pages, Author pages, etc the same place it is set for the homepage.  Which is in default.aspx.cs, at the very bottom of Page_Load.  Looks like lines 55, 56 and 57.

Aug 18, 2011 at 9:35 AM

I see it there.

Original Code:

Lines 55-57

        AddMetaKeywords();
        base.AddMetaTag("description", Server.HtmlEncode(BlogSettings.Instance.Description));
        base.AddMetaTag("author", Server.HtmlEncode(BlogSettings.Instance.AuthorName));       


---------------------------------------------------------------------------------------------------

        AddMetaKeywords();
        base.AddMetaTag("description", Server.HtmlEncode(Profile.AboutMe));   <----Want this to be for Author
        base.AddMetaTag("author", Server.HtmlEncode(BlogSettings.Instance.AuthorName));      

 

How do I access the Profile settings to get the "AboutMe"  info injected into the

<meta name="description" content=" Want Aboutme info here for description" />

Tried the Server.HtmlEncode(Profile.AboutMe));  method but not working.

My goal is to uniquely set each page with its own "Title" and "Description"  in the HTML meta name tags.

For the pages:

Category

Author List

Date

Tags

 

Instead of them all being set to one setting.

 

Thanks!!

 

Brian Davis

 

 

 

Coordinator
Aug 18, 2011 at 12:23 PM

Each of these types generally has its own function within default.aspx.cs.  e.g. DisplayAuthor(), DisplayTags(), etc.  What I would do is set the keywords and description within each of these functions.  And then move that existing code on lines 57 - 59 a few lines up so it is only used for the normal "homepage" requests.

Below is a modified version of DisplayAuthor() that retrieves the author's profile and outputs some of the profile information into the meta keywords/description fields.  The other profile information is available as well in the "ap" variable.  The new code starts in the middle.

private void DisplayAuthors()
{
	if (!string.IsNullOrEmpty(Request.QueryString["name"]))
	{
		string author = Server.UrlDecode(Request.QueryString["name"]);
		PostList1.ContentBy = ServingContentBy.Author;
		PostList1.Posts = Post.GetPostsByAuthor(author).ConvertAll(
			new Converter<Post, IPublishable>(delegate(Post p)
			{ return p as IPublishable; }));
		Title = "All posts by " + Server.HtmlEncode(author);

		AuthorProfile ap = AuthorProfile.GetProfile(author);
		if (ap != null)
		{
			string fullname = string.Format("{0} {1}",
				ap.FirstName, ap.LastName).Trim();

			base.AddMetaTag("description",
				string.Format("Posts by {0}", fullname));

			base.AddMetaTag("keywords",
				string.Format("{0} {1}", fullname, ap.CityTown));
		}
	}
}
Aug 18, 2011 at 9:20 PM

Thanks alot!!!!

 

I think I understand this way better thanks!!!

 

You are great BenAmada!!!!

Will ask more questions when I get them :)

 

Have a great day!!

Feb 14, 2012 at 3:55 PM

This is exactly what I need to do, but my skill set prevents me from understanding/modifying my own code.