Thêm Meta Tags vào 1 node của Drupal Content

Thêm Meta Tags vào 1 node của Drupal Content

Search engine optimization (SEO) is often at the top of the to-do list when planning a site.

There was a time when the <meta> tag had been considered one way to help your pages rise to the top of a search engine result. Although that is not always the case anymore, it can still be useful to meta tags available to search engines so they can use it if they choose.

In this tutorial, we'll explore the Meta tags module, a fast and easy way to add metadata to your nodes, terms, and users.

If you used the Nodewords module in Drupal 6, this is the best replacement in Drupal 7.

Meta tags and Drupal

If you view the page source of a Drupal node you will see <meta> tags like the ones below:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta content="test article summary" about="/node/4" property="dc:title" />

<meta about="/node/4" property="sioc:num_replies" content="0" datatype="xsd:integer" />

<meta name="Generator" content="Drupal 7 (" />

Depending on the type of Drupal page you view, you might see variations of this list but they all perform the same task, to provide information about the page to the search engine. When you install the Meta Tags module, the number of <meta> tags increase. For example, if you create an article and you include a summary from the body field and add an abstract and keywords via the meta tag module, you get the following tags.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta content="Meta Tag Test Article" about="/node/8" property="dc:title" />

<meta about="/node/8" property="sioc:num_replies" content="0" datatype="xsd:integer" />

<meta name="generator" content="Drupal 7 (" />

<meta name="keywords" content="keyword field, Drupal, Meta Tags Module, SEO" />

<meta name="abstract" content="This is the text from the abstract field in the Meta tags tab." />

<meta name="description" content="This is the text in the summary of the body field." />

Notice three additional <meta> tags have been added: keywords, abstract, and description.

Let's install the Meta tags module and see what else it can do.

Enable the modules

The Meta tags module requires you to install three modules:

You will see that the Meta Tags module comes with additional modules you can enable, depending on the needs of your site. In this tutorial, we are focusing on the default Meta Tags module.

Configure Meta Tags Module


The Meta Tags module comes already configured but you can make changes.

  1. Click on Configuration in the black admin menu bar.
  2. Click on Meta tags in the Search and Metadata box on the left side of the screen.

Notice there are four global settings. Click on each and observe what you get by default. All nodes, terms, and users will have the same configuration by default. But that doesn't have to be the case.

Add a Default Meta Tag


Lets configure the meta tags for the Article content type.

  1. Click on Add a meta tag default
  2. Selet Article from the Type dropdown.
  3. Enter the token [node:content-type:description] in the abstract field.
  4. Save

When you create an Article node from now on, the description of the Article content type will appear as such:

<meta name="abstract" content="Use articles for time-sensitive content like news, press releases or blog posts." />

Notice the Inheritance


The Article content type is node, obviously, therefore it appears under the Node metatag. You may have noticed that the default tokens were included in the Article meta tag. That's because they were inherited but that doesn't mean you can't provided something else.

For example, you could place the [node:summary] token in the abstract and the [node:content-type:description] in the Description, it's up to you. Of course there are other tokens you can choose from (see the link "Browse available tokens" at the bottom of the token edit form).

Let's see what this does when we create a node


Go to Add content and add an Article. Scroll down and click on the Meta tags tab. Notice your options. We can see the token we added to the Articles meta tag but notice we can also edit these fields. Your users can do the same if they have permission.

Do users have to enter meta tag data?

The answer is no. As we have demonstrated so far, the fields in the meta tag module can be populated using the data associated with the token. For example, if we return the Configuration > Meta tags and click edit for the Article meta tag, we can add the token for the tag field that comes with the Article content type. This will automatically include the terms your user inserts into the Tags field.

For my example, I entered the term Drupal into the Tags field and now my meta tag reflects the same.

<meta name="keywords" content="Drupal" />

Terms and Users

The process is the same when setting up meta data for vocabulary terms and users. As you might have guessed, your users might have the ability to add vocabulary terms to the Tags field but they aren't given the opportunity to add meta data for that term. This is something you will need to take into consideration when planning the user of meta data via the Meta Tags module.



The permissions for the Meta Tags module are simple. You can administer and you can edit if you have permission to edit the node, term, or user. Another thing to note is the edit feature is an all or nothing deal. You might want to give users access to edit their meta data but restrict their ability to edit the meta data when they create a node. At this time, the level of permission granularity does not appear to an option.


The power of the token makes this Meta Tags module a handy tool. It's one thing to get someone to enter data into the fields you provide, it might be another to get them to do the same for meta data. The tokens solve this problem and give you the option to control what you want to be included - making this an SEO feature that runs itself.

Note - When I created this tutorial, I noticed that the text I enter for the abstract and keyword for terms and users was not available if I wanted to edit it, like it was for a node. The data was stored and continued to display when I viewed the source of the page. There are a couple of patches located here and the developers are asking that we test it for them.

See more: Thêm Metadata cho Drupal Nodes để Seo

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Tìm kiếm bất động sản





Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

Làm sao để Lion không tự động sửa lỗi từ khi gõ?

Làm sao để Lion không tự động sửa lỗi từ khi gõ?

Gõ đúng nhưng lại bị Lion "autocorrect"? Giải pháp đây!

Siri: Chỉnh sửa hình ảnh bằng... giọng nói

Siri: Chỉnh sửa hình ảnh bằng... giọng nói

Văn phòng Bản quyền thương hiệu Mỹ (USPTO) vừa tiết lộ một bản quyền mà Apple đã đăng kí, cho thấy trong tương lai tính năng Siri (trợ lí ảo thông minh) sẽ có khả năng điều khiển các tấm hình trên máy bằng giọng nói.


Triển lãm Palme Việt Nam về thiết bị nghe - nhìn, âm thanh, ánh sáng...

Triển lãm Quốc tế lần thứ 3 tại Việt Nam về Thiết bị Nghe – Nhìn, Âm thanh – Ánh sáng chuyên nghiệp, Truyền hình, Tích hợp hệ thống và Công nghệ giải trí sẽ trở lại Thành phố Hồ Chí Minh sau một năm vắng bóng.

Wordpress Freelancer


Wordpress Freelancer