2017-01-16 75 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/