{"id":16182247,"url":"https://github.com/avraammavridis/angular-metatags","last_synced_at":"2025-03-19T02:30:38.646Z","repository":{"id":27673249,"uuid":"31159282","full_name":"AvraamMavridis/angular-metatags","owner":"AvraamMavridis","description":"Module for providing dynamic Meta Tags to Angular routes ","archived":false,"fork":false,"pushed_at":"2018-08-06T14:26:23.000Z","size":100,"stargazers_count":63,"open_issues_count":2,"forks_count":29,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-28T05:53:06.435Z","etag":null,"topics":["angular","angular-metatags","meta-tags","seo"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AvraamMavridis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-22T10:14:03.000Z","updated_at":"2022-12-13T13:09:04.000Z","dependencies_parsed_at":"2022-08-21T02:40:41.789Z","dependency_job_id":null,"html_url":"https://github.com/AvraamMavridis/angular-metatags","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvraamMavridis%2Fangular-metatags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvraamMavridis%2Fangular-metatags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvraamMavridis%2Fangular-metatags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvraamMavridis%2Fangular-metatags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AvraamMavridis","download_url":"https://codeload.github.com/AvraamMavridis/angular-metatags/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960361,"owners_count":20375101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular-metatags","meta-tags","seo"],"created_at":"2024-10-10T06:29:55.034Z","updated_at":"2025-03-19T02:30:38.063Z","avatar_url":"https://github.com/AvraamMavridis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Angular MetaTags module**\n\nModule to dynamically provide metatags based on the path. After this [PR](https://github.com/AvraamMavridis/angular-metatags/pull/5) it supports both ngRoute and ui-router (only simple states).\n\n## **How to use it**\n\n#### Include `angular-metatags.js` or `angular-metatags.min.js` to your html file before your app script and after the angular's core script\n\n```html\n\u003cscript src=\"bower_components/angular/angular.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"bower_components/angular-route/angular-route.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"scripts/angular-metatags.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"scripts/mainApp.js\"\u003e\u003c/script\u003e\n```\n\n#### Include the module in your app\n\n```js\nvar myApp = angular.module('myApp', ['ngRoute','metatags']);\n```\n\n#### Inject the MetaTagsProvider in the config and define your meta tags\n```js\nmyApp.config(['$routeProvider','MetaTagsProvider', function($routeProvider, MetaTagsProvider) {\n\n        ...\n        ...\n        \n        MetaTagsProvider\n          .when('/', {\n            title: 'Great',\n            description: 'Cool'\n            fb_title: 'My title'\n            fb_site_name: 'My site name' \n            fb_url: 'www.blablabla.blabla' \n            fb_description: 'Cool website'\n            fb_type: 'Facebook type'\n            fb_image: 'an_image.jpg' \n          })\n          .when('/page1/:parameter1/:parameter2',{\n            title: 'Page 1 :something',\n            description: function(parameter1, parameter2){\n                return 'COOOOOOOL' + parameter1 + \" Super \" + parameter2;\n            }\n            robots: 'index, follow'\n            keywords: 'some cool keywords'\n          })\n          .when('/page2/:parameter1',{\n            title: 'Page 2 of :parameter1',\n            description: 'Another great page'\n          })\n          .otherwise({\n            title: 'otherwise',\n            description: 'Another great page'\n          })\n    }]);\n```\n\n`when` Accepts a string with the path and an object with metatags `when(path,metatags)` The path can contain parameters, each parameter should start with `:` . Each attribute of the metatags object can be a string or a function that returns a string. The string can contain a parameter that will be replaced. If the path contain parameters and an attribute of the metatags object is a function the parameters are passed to that function. \n###### Example\nIf we define a route like this\n```js\n.when('/page1/:parameter1/:parameter2',{\n    title: 'Books of :parameter1 by :parameter2',\n    description: function(parameter1, parameter2){\n      return 'We have great books of ' + parameter1.toUpperCase() + ' by the amazing :parameter2';\n    },\n    robots: 'index, follow',\n    keywords: function(parameter1){\n      var keywords = ['history', 'art', 'music']\n      keywords.push(parameter1);\n      return keywords.join(' ');\n    }\n})\n```\nand we visit the path `/page1/geography/nationalgeographic` We will have the following object of metatags:\n\n```js\n$rootScope.metatags =  { \n  title: \"Books of geography by nationalgeographic\", \n  description: \"We have great books of GEOGRAPHY by the amazing nationalgeographic\", \n  robots: \"index, follow\", \n  keywords: \"history art music geography\" \n}\n```\n#### Initialize the provider on your application run\n```js\nmyApp.run(function(MetaTags){\n    MetaTags.initialize();\n});\n```\n#### Include the metatags in your html\n\nYou can use the metatags in our html like this:\n```html\n  \u003ctitle\u003e{{ metatags.title }}\u003c/title\u003e\n  \u003cmeta name=\"description\" content=\"{{ metatags.description }}\" \u003e\n  \u003cmeta name=\"robots\" content=\"{{ metatags.robots }}\" \u003e\n  \u003cmeta name=\"keywords\" content=\"{{ metatags.keywords }}\" \u003e\n  \u003c!-- Facebook related metatags --\u003e\n  \u003cmeta property=\"fb:app_id\"          content=\"{{ metatags.fb_app_id }}\" \u003e \n  \u003cmeta property=\"og:url\"             content=\"{{ metatags.fb_url }}\"  \u003e \n  \u003cmeta property=\"og:title\"           content=\"{{ metatags.fb_title }}\" \u003e \n  \u003cmeta property=\"og:image\"           content=\"{{ metatags.fb_image }}\"  \u003e \n  \u003cmeta property=\"og:description\"     content=\"{{ metatags.fb_description }}\"  \u003e\n  \u003cmeta property=\"og:site_name\"       content=\"{{ metatags.fb_site_name }}\" \u003e\n  \u003cmeta property=\"og:type\"            content=\"{{ metatags.fb_type }}\" \u003e\n```\n\n## Angular and SEO\n\nUntil the search engine bots will be able to execute javascript properly you will have to use a tool like [prerender.io](https://prerender.io/) or [brombone](http://www.brombone.com/) to serve prerendered pages when a bot visit your site. \nYou can read more for the topic on the following articles:\n\n-[Weluse.de - Angular \u0026 SEO finally a piece of cake](https://weluse.de/blog/angularjs-seo-finally-a-piece-of-cake.html)\n\n-[Builtvisible.com - The Basics of JavaScript Framework SEO in AngularJS](http://builtvisible.com/javascript-framework-seo/)\n\n-[Yearofmoo.com - AngularJS and SEO](http://www.yearofmoo.com/2012/11/angularjs-and-seo.html)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favraammavridis%2Fangular-metatags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favraammavridis%2Fangular-metatags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favraammavridis%2Fangular-metatags/lists"}