Moz Q&A is closed.
After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.
How to auto generate a unique meta description?
- 
					
					
					
					
 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: 
- 
					
					
					
					
 Perfect! Glad to hear it's all fixed  
- 
					
					
					
					
 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! 
- 
					
					
					
					
 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 
- 
					
					
					
					
 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. 
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
- 
		
		Moz ToolsChat with the community about the Moz tools. 
- 
		
		SEO TacticsDiscuss the SEO process with fellow marketers 
- 
		
		CommunityDiscuss industry events, jobs, and news! 
- 
		
		Digital MarketingChat about tactics outside of SEO 
- 
		
		Research & TrendsDive into research and trends in the search industry. 
- 
		
		SupportConnect on product support and feature requests. 
Related Questions
- 
		
		
		
		
		
		Video titles and descriptions
 Hi everyone, I have a question about embedding videos on a website: if you optimize the title and description for the video in Youtube, will these be taken into account for the ranking of the page where the video is embedded? Or will only the Youtube link for the video show in SERP's, instead of the page itself? I've read in a post of Phil Nottingham that it's usually not a good idea to embed a Youtube video on your own site, but use Wistia instead, exactly to avoid cannibalisation of your own rankings. Is this correct? Thanks! Intermediate & Advanced SEO | | Mat_C0
- 
		
		
		
		
		
		Do I need to add the actual language for meta tags and description for different languages? cited for duplicate content for different language
 Hi, I am fairly new to SEO and this community so pardon my questions. We recently launched on our drupal site mandarin language version for the entire site. And when i do the crawl site, i get duplicate content for the pages that are in mandarin. Is this a problem or can i ignore this? Should i make different page titles for the different languages? Also, for the metatag and descriptions, would it better in the native language for google to search for? thanks in advance. Intermediate & Advanced SEO | | lynetteboss0
- 
		
		
		
		
		
		Sitemap: unique sitemap or different sitemaps by Country
 Hi guys, i have a question about sitemaps. We are doing an international site, e.x. www.offers.com for landing page and www.offers.com/br for brazil, www.offers.com/it for italy, etc... i don't if we should do an unique sitemap for all countries or separate sitemaps by country, e.x.: unique sitemap: www.offers.com/sitemap.xml - including all sitemaps www.offers.com/br/sitemap.xml - sitemap for brazil market only. Thank you Intermediate & Advanced SEO | | thekiller990
- 
		
		
		
		
		
		Meta Robot Tag:Index, Follow, Noodp, Noydir
 When should "Noodp" and "Noydir" meta robot tag be used? I have hundreds or URLs for real estate listings on my site that simply use "Index", Follow" without using Noodp and Noydir. Should the listing pages use these Noodp and Noydr also? All major landing pages use Index, Follow, Noodp, Noydir. Is this the best setting in terms of ranking and SEO. Thanks, Alan Intermediate & Advanced SEO | | Kingalan10
- 
		
		
		
		
		
		Unique domains vs. single domain for UGC sites?
 Working on a client project - a UGC community that has a DTC model as well as a white label model. Is it categorically better to have them all under the same domain? Trying to figure which is better: XXX,XXX pages on one site vs. A smaller XXX,XXX pages on one site and XX,XXX pages on 10-20 other sites all pointing to the primary site. The thinking on the second was that those domains would likely achieve high DA as well as the primary, and would passing their value to the primary. Thoughts? Any other considerations we should be thinking about? Intermediate & Advanced SEO | | intentionally0
- 
		
		
		
		
		
		Should you include domain / brand in Meta Title
 Hello, I am trying to come up with a strategy for creating meta title information for my eCommerce store. I have read mixed reviews on the examples below. The first includes the company / brand in the meta title and thus is included in SE results. The second does not. Probably not a 'right' answer here so I look forward to answers with rationale... also open to a completely difference strategy all together! 1MR Vortex by BPI Sports - $Company_Name OR 1MR Vortex by BPI Sports - Pre Workout Supplement Thanks! Intermediate & Advanced SEO | | 6thirty0
- 
		
		
		
		
		
		Generating 404 Errors but the Pages Exist
 Hey I have recently come across an issue with several of a sites urls being seen as a 404 by bots such as Xenu, SEOMoz, Google Web Tools etc. The funny thing is, the pages exist and display fine. This happens on many of the pages which use the Modx CMS, but the index is fine. The wordpress blog in /blog/ all works fine. The only thing I can think of is that I have a conflict in the htaccess, but troubleshooting this is difficult, any tool I have found online seem useless. Have tried to rollback to previous versions but still does not work. Anyone had any experience of similar issues? Many thanks K. Intermediate & Advanced SEO | | Found0
- 
		
		
		
		
		
		Some viagra spammer somehow fooled Google into thinking the title and description metatags of a site pointing to me are about viagra. How did they do that? How do I fix this?
 In performing a link: to my site, I found this: Video Of People Using Viagra - Online Drug Store, Guaranteed Shipping <cite>www.planetherbs.com/affiliate-program.html</cite> - Cached -Block all www.planetherbs.com results1 day ago – Video Of People Using Viagra. Online Drug Store, Guaranteed Shipping. Check Order Status. Natural and healthy products! If you go to that url, you will see it's just an affiliate program page. Some viagra spammer somehow changed the title and description metatags that google sees (not actually) and links from what appears to be spammy pages are pointing to me. I don't want to get dinged for this. How do I fix these for myself and planetherbs.com? And how did the spammer do this??? Intermediate & Advanced SEO | | KatMouse0
 
			
		 
			
		 
			
		 
					
				 
					
				 
					
				 
					
				 
					
				 
					
				 
					
				