# Meta description from page part

**URL:** <https://www.ruby-forum.com/t/meta-description-from-page-part/118772>\
**Category:** Radiant CMS\
**Created:** [October 30, 2007, 8:22pm UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772 "2007-10-30T20:22:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewneal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@andrewneal](https://www.ruby-forum.com/u/andrewneal)\
**Post date:** [October 30, 2007, 8:22pm UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772/1 "2007-10-30T20:22:30Z")

</div>

I would like to insert a meta description into my pages. This would  
be of the form:

I realise that it would not be correct to use the following construct:

Is there any way to insert the output from a radius tag into the  
attribute (in this case content="") of a tag?

Another approach, I suppose, would be to define a custom radius tag  
for the purpose. An example usage being:

\<r:meta name=“description” part=“meta\_description” /\>

which could output:

Am I thinking along the right lines? Has anyone already written an  
extension which achieves this, or should I dive right in?

Thanks,

Drew

---

<div class="post-metadata">

**Author:** ![andrewneal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@andrewneal](https://www.ruby-forum.com/u/andrewneal)\
**Post date:** [October 30, 2007, 8:35pm UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772/2 "2007-10-30T20:35:22Z")

</div>

I have a really “dumb” (as in simple) extension that adds description  
and keywords Radius tags and fields on the Page model. If you like, I  
could open-source it.

Sean

---

<div class="post-metadata">

**Author:** ![andrewneal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@andrewneal](https://www.ruby-forum.com/u/andrewneal)\
**Post date:** [October 30, 2007, 8:41pm UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772/3 "2007-10-30T20:41:12Z")

</div>

> I realise that it would not be correct to use the following construct:  
> \<meta name=“Description” content=“\<r:content part=“meta\_description””\>

You can actually use that construct, just be sure to close the  
\<r:content\> tag.

Although Radius’s documentation ([http://radius.rubyforge.org/](http://radius.rubyforge.org/)) does  
not  
say it explicitly (AFAIK), the current Radius implementation allows  
this.

I remember that few months ago i stated the opposite in this list, i  
was  
wrong.

/AITOR

---

<div class="post-metadata">

**Author:** ![andrewneal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@andrewneal](https://www.ruby-forum.com/u/andrewneal)\
**Post date:** [October 31, 2007, 11:06am UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772/4 "2007-10-31T11:06:18Z")

</div>

> Although Radius’s documentation ([http://radius.rubyforge.org/](http://radius.rubyforge.org/)) does  
> not  
> say it explicitly (AFAIK), the current Radius implementation allows  
> this.

Are you sure? I can’t seem to make it work. I’ve tried this:

```
 <meta name="description" content='<r:content

```

part=“meta\_description”/\>'/\>

and also this (swapping single and double quotes):

```
 <meta name="description" content="<r:content

```

part=‘meta\_description’/\>"/\>

Both create the following output:

Am I doing it wrong?

Drew

---

<div class="post-metadata">

**Author:** ![andrewneal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@andrewneal](https://www.ruby-forum.com/u/andrewneal)\
**Post date:** [October 31, 2007, 11:08am UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772/5 "2007-10-31T11:08:43Z")

</div>

> I have a really “dumb” (as in simple) extension that adds description  
> and keywords Radius tags and fields on the Page model. If you like, I  
> could open-source it.

That would be great. Do give us a shout if you find the time to do  
that. In the mean time, I might have a go at it myself. It would be  
my first Radiant extension, and it sounds suitably easy.

Thanks

Drew

---

<div class="post-metadata">

**Author:** ![andrewneal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@andrewneal](https://www.ruby-forum.com/u/andrewneal)\
**Post date:** [October 31, 2007, 11:41am UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772/6 "2007-10-31T11:41:51Z")

</div>

I tried your example below and it works for me. Check:

- that the page part exists
- that you clear the cache before testing your changes

/AITOR

---

<div class="post-metadata">

**Author:** ![andrewneal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@andrewneal](https://www.ruby-forum.com/u/andrewneal)\
**Post date:** [October 31, 2007, 12:18pm UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772/7 "2007-10-31T12:18:15Z")

</div>

On 31 Oct 2007, at 10:40, Aitor Garay-Romero wrote:

> I tried your example below and it works for me. Check:
> 
> - that the page part exists

Doh! This was my problem. I was testing on a page where I hadn’t  
added the page part.

Thanks for your troubleshooting!

Now to the matter of whether Radius should allow this. I had assumed  
it would not be possible, because code such as

> 

is not valid XML. One of the things I like about Radius, as compared  
with Liquid layouts for e.g., is that it uses tags which a text  
editor with HTML syntax highlighting can recognise. I presume that  
this is deliberate. A construct like the one above is evidently  
useful, but it breaks this XML namespace. So doesn’t that go against  
the purpose of Radius? Any thoughts?

Drew

---

<div class="post-metadata">

**Author:** ![andrewneal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@andrewneal](https://www.ruby-forum.com/u/andrewneal)\
**Post date:** [November 9, 2007, 11:16pm UTC](https://www.ruby-forum.com/t/meta-description-from-page-part/118772/8 "2007-11-09T23:16:39Z")

</div>

Hi,

Reviving this old thread.

On 30 Oct 2007, at 19:34, Sean C. wrote:

> I have a really “dumb” (as in simple) extension that adds description  
> and keywords Radius tags and fields on the Page model. If you like, I  
> could open-source it.

I’ve had a go at this myself, and wanted to compare notes with you.  
Here is the description of what my tag does:

> Usage is similar to the @\<r:content /\>@ tag, with @inherit@ causing  
> the parent page part to be used if this page does not have one. By  
> default, this is set to true.
> 
> Only suitable for use in @@ section of a document.
> 
> _Usage:_
> 
> ```
> 
> ```

I also wondered about making it strip the length of the content  
attribute to 200 characters (configurable), as this is the upper  
limit recommended by search engines. Here is a link to the article  
that got me thinking about this in the first place: http://  
[www.seobook.com/video-optimizing-meta-description-tags-google](http://www.seobook.com/video-optimizing-meta-description-tags-google)

It makes for a pretty lame extension by itself, so I wondered whether  
it might be considered for the standard tags? Once I’ve written some  
tests…

Any thoughts?

Drew
