Click here to Skip to main content
Click here to Skip to main content

HTML Meta Tag Generator

, 15 Jan 2007
Rate this:
Please Sign up or sign in to vote.
Visual HTML Meta Tag Generator

Sample Image - Meta_Tag_Generator.jpg

Introduction

Because of how often I need to generate Meta Tags for my web pages, and how difficult it is to remember all meta attributes (description, author... etc) I decided to write an application (small one) to do this job for me every time I need (create a new page for my sites).

This set of meta tags is not complete, a meta tag can have many different attributes, but this program i created is only for the ones i use most often(for full list of attributes: ask Google!)

I will generate the tags with only these attributes:
title, description, keywords, author, distribution and revisit

Let's start to create an Object - MetaTagObj to store all the information we need inside.
The code for MetaTagObj class is:

using System;

namespace MetaTagGenerator
{
    class MetaTagObj
    {
        private string title;
        private string desc;
        private string keys;
        private string author;
        private string distribution;
        private string revisit;

        public string Title
        {
            get { return title; }
            set { title = value.Trim(); }
        }
        public string Desc
        {
            get { return desc; }
            set { desc = value.Trim(); }
        }
        public string Keys
        {
            get { return keys; }
            set { keys = value.Trim(); }
        }
        public string Author
        {
            get { return author; }
            set { author = value.Trim(); }
        }
        public string Distribution
        {
            get { return distribution; }
            set 
            {
                if (value.Trim() == "")
                {
                    distribution = "Global";  //default value
                    return;
                }
                distribution = value.Trim(); 
            }
        }
        public string Revisit
        {
            get { return revisit + " Days"; }
            set 
            {
                if (value.Trim() == "")
                {
                    revisit = "10";
                    return;
                }
                revisit = value.Trim();
            }
        }

        public MetaTagObj(): this("Title here", "Description Here", "", "", "", "")
        {
        }
        public MetaTagObj(string title, string desc, string keys, string author, string distribution, string revisit)
        {
            Title = title;
            Desc = desc;
            Keys = keys;
            Author = author;
            Distribution = distribution;
            Revisit = revisit;
        }
        public override string ToString()
        {
            string MetaTag = "";
            MetaTag += "<title>"+ Title + "</title>" + Environment.NewLine;
            MetaTag += "<meta name=\"description\" content=\"" + Desc + "\" />" + Environment.NewLine;
            MetaTag += "<meta name=\"keywords\" content=\"" + Keys + "\" />" + Environment.NewLine;
            MetaTag += "<meta name=\"author\" content=\"" + Author + "\" />" + Environment.NewLine;
            MetaTag += "<meta name=\"distribution\" content=\"" + Distribution + "\" />" + Environment.NewLine;
            MetaTag += "<meta name=\"revisit-after\" content=\"" + Revisit + "\" />" + Environment.NewLine;

            return MetaTag;
        }
    }
}

In this class I do all the work for Meta tag creation (also, I include the TITLE tag here). This class is simple, two constructors, one with parameters, one empty. Some properties for private variables, with some default values (some of them).

The main form contains (screen capture on top of page) few TextBoxes, where the user can introduce data (values for specific attribute.), 3 buttons (Generate, Copy to Clipboard and About) and a TextBox (ReadOnly) for generated code!

. To use this program, you need to fill all the textboxes you want and to press the Generate Button. After this just Copy/Paste the code inside your HTML doc, on HEAD section.

Enjoy!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

zeltera
Engineer
Israel Israel
No Biography provided

Comments and Discussions

 
GeneralMy vote of 1 Pinmemberraphaelsainfocon13-Jun-09 0:43 
GeneralMy vote of 1 PinmemberBooGhost20-May-09 17:31 
This is nothing more than parroting user input. It does not show off anything besides the most basic of language syntax.
GeneralString concatenation PinmemberPaulo Morgado16-Jan-07 22:54 
AnswerRe: String concatenation Pinmemberzeltera16-Jan-07 23:23 
GeneralRe: String concatenation PinmemberPaulo Morgado17-Jan-07 14:22 
GeneralRe: String concatenation Pinmemberzeltera18-Jan-07 0:10 
GeneralRe: String concatenation Pinmemberzeltera18-Jan-07 1:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 15 Jan 2007
Article Copyright 2007 by zeltera
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid