The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Intermediate & Advanced SEO
    4. How to auto generate a unique meta description?

    How to auto generate a unique meta description?

    Intermediate & Advanced SEO
    5 3 6.0k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DanDeceuster
      DanDeceuster last edited by

      The site I am working on is a code nightmare for starters. I'm editing a file called layout that controls the section of each page. The programmer from a while back got unique titles by putting this piece of code in:

      <title><?= $this->metaTag ?></title>

      In all the different controllers and stuff I can see where the title is the name of the product plus review or something to that effect.

      How do I do this for the meta description? Right now the meta description is static in the layout file, and so every page has an identical one. I was hoping there was a way to make the meta description automatically use the first 140 characters on the page or something. Something like this:

      1 Reply Last reply Reply Quote 0
      • seoninja20
        seoninja20 last edited by

        I just did a large 5k page website with the same kind of auto generation, It worked very well. I'm not sure how your website is setup and if the content is all on the database but ours is and we just had to fill in some variables like this.

        <title><?=ucfirst($ctar[county_name]);?> Jail, <?=$star[state_name];?> | Bail Bonds & Lawyer Resources</title>

        Most likely you are looking for something like strip tags.

        http://www.daniweb.com/web-development/php/threads/285226

        http://php.net/manual/en/function.strip-tags.php

        1 Reply Last reply Reply Quote 1
        • ShaMenz
          ShaMenz last edited by

          Hi Daniel,

          The first thing you need to do is to find the definition of the container that “this” is built out of and then add an element called metaDescription.

          This will create an empty string until you populate it elsewhere.

          Now where you want metaDescription shown, you just use

          <title><?= $this->metaDescription ?></title> (replace metaTag with metaDescription).

          Next, you need to search your code for the place where metaTag is assigned and add an assignment for metaDescription which can be whatever you want it to be ie a substring etc.

          Hope that helps,

          Sha

          DanDeceuster 1 Reply Last reply Reply Quote 1
          • DanDeceuster
            DanDeceuster @ShaMenz last edited by

            This worked like a charm! The site is on something called Zend cart I think and I had to sort through several Controllers but eventually found all the metaTag stuff in there and added a metaDesc variable next to them, unique meta descriptions on every page! Thanks!

            ShaMenz 1 Reply Last reply Reply Quote 0
            • ShaMenz
              ShaMenz @DanDeceuster last edited by

              Perfect!

              Glad to hear it's all fixed 🙂

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              • Meta Description
                seoanalytics
                seoanalytics
                0
                4
                58

              • New meta description limit?
                Alick300
                Alick300
                0
                2
                193

              • Mobile Meta Descriptions
                ClaytonJ
                ClaytonJ
                0
                3
                557

              • What is better for Meta description ??
                BradsDeals
                BradsDeals
                0
                9
                199

              • Error Meta Description
                LinkWheelOldSchool
                LinkWheelOldSchool
                0
                4
                451

              • Google not displaying meta description
                donford
                donford
                0
                5
                97

              • Does it matter if the meta description and meta keywords come before the title tag in the
                KeriMorgret
                KeriMorgret
                0
                9
                2.3k

              • Help with Effective Meta Description
                DanielFreedman
                DanielFreedman
                0
                5
                256

              Get started with Moz Pro!

              Unlock the power of advanced SEO tools and data-driven insights.

              Start my free trial
              Products
              • Moz Pro
              • Moz Local
              • Moz API
              • Moz Data
              • STAT
              • Product Updates
              Moz Solutions
              • SMB Solutions
              • Agency Solutions
              • Enterprise Solutions
              • Digital Marketers
              Free SEO Tools
              • Domain Authority Checker
              • Link Explorer
              • Keyword Explorer
              • Competitive Research
              • Brand Authority Checker
              • Local Citation Checker
              • MozBar Extension
              • MozCast
              Resources
              • Blog
              • SEO Learning Center
              • Help Hub
              • Beginner's Guide to SEO
              • How-to Guides
              • Moz Academy
              • API Docs
              About Moz
              • About
              • Team
              • Careers
              • Contact
              Why Moz
              • Case Studies
              • Testimonials
              Get Involved
              • Become an Affiliate
              • MozCon
              • Webinars
              • Practical Marketer Series
              • MozPod
              Connect with us

              Contact the Help team

              Join our newsletter
              Moz logo
              © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
              • Accessibility
              • Terms of Use
              • Privacy