Tạo URL đẹp cho Drupal site với Pathauto Module

Tạo URL đẹp cho Drupal site với Pathauto Module

This tutorial was requested by a student who is learning the Drupal basics. They turned on "Clean URLs" in the Drupal admin area and were surprised to see that the URLs remained largely unchanged:

  • Old: /?q=node/3
  • New: /node/3

The student's comment was:

"that's still a silly address for my About Us page. I want the address to be /about-us/."

We also tried to help them by turning on the Path module in the Drupal core. That allowed them to create URLs like /about-us/ however they still needed to think about it and ask their users to create a path every time. They wanted something that would create great URLs automatically.

The solution is the "Pathauto" module and let's show you how to set it up:

Installing Pathauto to Your Drupal Site

In fact, we're going to install two modules because Pathauto also requires the "Token" module.

  • Step 1: Go to Administer >> Site configuration >> Clean URLs to check that they are enabled.
  • Step 2: Click here to download the latest version of "Pathauto" and click here for "Token".
  • Step 3: Extract the files into a two folders on your desktop. One  folder will be called "pathauto" and the other "token".
  • Step 4: Login to your site's files via FTP and navigate to /sites/all/. If there isn't a folder called /modules/ here, create one.
  • Step 5: Upload the "sections" folder to /sites/all/modules/
  • Step 6: Go to Administer >> Site building >> Modules. You'll need to check four boxes:

    Improving Drupal's Clean URLs with the Pathauto Module

  • Step 7: Go and create a new node. When you do, you should notice a new area labelled "URL path settings". If you leave "Automatic alias" checked, the address of the page will likely be your Page title in this format:
    /content/your-page-title/

    Enable Drupal Pathauto

Configuring Pathauto

The default Pathauto setting might not be to everyone's taste:

  • You may want to use underscores _ instead of dashes as this student did.
  • You may want to remove /content/ so that you really can have pages with the address /about-us/ rather than /content/about-us/

To change the settings, go to Administer >> Site building >> URL aliases >> Automated Alias Settings:

Drupal Pathauto Settings

Bạn thấy bài viết này như thế nào?: 
Average: 4.5 (2 votes)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Bình luận (0)

 

Add Comment

Filtered HTML

  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Các thẻ HTML được chấp nhận: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Tự động ngắt dòng và đoạn văn.

Plain text

  • No HTML tags allowed.
  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Tự động ngắt dòng và đoạn văn.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

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

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

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

 
Tăng dự trữ bằng đồng euro, Nga mất hơn 30 tỷ USD

Tăng dự trữ bằng đồng euro, Nga mất hơn 30 tỷ USD

Theo báo Độc lập (Nga), Nga đã mất hơn 30 tỷ USD trong năm 2011 do đồng euro mất giá. Trong dự trữ ngoại tệ của Nga, đồng euro chiếm hơn 40%, cao hơn đáng kể hơn so với mức ở các nước khác.

Bật Graph metatags cho Drupal content types

Let's do Open Graph metatags for Drupal content types with the brand new Meta tag module!

Cludo + Drupal = Instant User-Friendly Search

Thử trải nghiệm Friendly Search của Cludo module trên Drupal 8

Search is a key feature in web experience, and for a lot of people, it's the go-to method to find content. We use search countless times a day on our smartphones in various contexts.

Công ty diệt chuột T&C

 

Diet con trung