2017-01-16 94 views
-5

夥計!需要幫助。我正在開發一個關於Angular的項目,我的PM要求我執行其SEO優化。我不知道從哪裏開始。你能給我一個代碼示例嗎?Angular.JS項目的SEO優化

回答

-1

首先,你應該形成標題元標籤和描述。

const metaTags = { 
    get(metaTagName) { 
     switch (metaTagName) { 
      case `titleMeta`: 
       return angular.element(`meta[property="og:title"]`); 
      case `descriptionMeta`: 
       return angular.element(`meta[property="og:description"], meta[name="description"]`); 
     } 
    } 

}

現在,你必須創建將通過參數收到我們的標題字符串形式的功能。

const metaTags = { 
    get(metaTagName) { 
     switch (metaTagName) { 
      case `titleMeta`: 
       return angular.element(`meta[property="og:title"]`); 
      case `descriptionMeta`: 
       return angular.element(`meta[property="og:description"], meta[name="description"]`); 
     } 
    }, 

    set({ title, description }) { 
     if (!angular.isUndefined(title)) { 
      this.get(`titleMeta`).prop(`content`, title); 
     } 
     if (!angular.isUndefined(description)) { 
      this.get(`descriptionMeta`).prop(`content`, description); 
     } 
    } 
} 

第一步通過。本文將幫助您非常快捷地完成SEO優化過程。 http://computoolsglobal.com/blog/angular-seo-optimization/