{"id":13630526,"url":"https://github.com/pgilad/gulp-sitemap","last_synced_at":"2025-08-20T10:31:58.768Z","repository":{"id":14612154,"uuid":"17329433","full_name":"pgilad/gulp-sitemap","owner":"pgilad","description":"Generate a search engine friendly sitemap.xml using a Gulp stream","archived":false,"fork":false,"pushed_at":"2020-12-08T23:32:07.000Z","size":155,"stargazers_count":61,"open_issues_count":4,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-10T00:42:03.411Z","etag":null,"topics":["gulp","gulp-plugin","javascript","seo","xml","xml-tags"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgilad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-02T02:38:52.000Z","updated_at":"2024-11-27T14:06:57.000Z","dependencies_parsed_at":"2022-09-19T02:01:24.463Z","dependency_job_id":null,"html_url":"https://github.com/pgilad/gulp-sitemap","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Fgulp-sitemap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Fgulp-sitemap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Fgulp-sitemap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Fgulp-sitemap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgilad","download_url":"https://codeload.github.com/pgilad/gulp-sitemap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230415318,"owners_count":18222158,"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":["gulp","gulp-plugin","javascript","seo","xml","xml-tags"],"created_at":"2024-08-01T22:01:45.879Z","updated_at":"2024-12-19T10:09:21.028Z","avatar_url":"https://github.com/pgilad.png","language":"JavaScript","readme":"# [gulp](https://github.com/wearefractal/gulp)-sitemap\n\u003e Generate a search engine friendly sitemap.xml using a Gulp stream\n\n[![NPM version](http://img.shields.io/npm/v/gulp-sitemap.svg?style=flat)](https://www.npmjs.org/package/gulp-sitemap)\n[![NPM Downloads](http://img.shields.io/npm/dm/gulp-sitemap.svg?style=flat)](https://www.npmjs.org/package/gulp-sitemap)\n[![Build Status](http://img.shields.io/travis/pgilad/gulp-sitemap/master.svg?style=flat)](https://travis-ci.org/pgilad/gulp-sitemap)\n\nEasily generate a search engine friendly sitemap.xml from your project.\n\n:bowtie: Search engines love the sitemap.xml and it helps SEO as well.\n\nFor information about sitemap properties and structure, see the [wiki for sitemaps](http://www.wikiwand.com/en/Sitemaps)\n\n## Install\n\nInstall with [npm](https://npmjs.org/package/gulp-sitemap)\n\n```bash\n$ npm install --save-dev gulp-sitemap\n```\n\n## Example\n\n```js\nvar gulp = require('gulp');\nvar sitemap = require('gulp-sitemap');\n\ngulp.task('sitemap', function () {\n    gulp.src('build/**/*.html', {\n            read: false\n        })\n        .pipe(sitemap({\n            siteUrl: 'http://www.amazon.com'\n        }))\n        .pipe(gulp.dest('./build'));\n});\n```\n\n* `siteUrl` is required.\n* `index.html` will be turned into directory path `/`.\n* `404.html` will be skipped automatically. No need to unglob it.\n\nLet's see an example of how we can create and output a sitemap, and then return to the original stream files:\n```js\nvar gulp = require('gulp');\nvar sitemap = require('gulp-sitemap');\nvar save = require('gulp-save');\n\ngulp.task('html', function() {\n    gulp.src('*.html', {\n          read: false\n        })\n        .pipe(save('before-sitemap'))\n        .pipe(sitemap({\n                siteUrl: 'http://www.amazon.com'\n        })) // Returns sitemap.xml\n        .pipe(gulp.dest('./dist'))\n        .pipe(save.restore('before-sitemap')) //restore all files to the state when we cached them\n        // -\u003e continue stream with original html files\n        // ...\n});\n```\n\n## Options\n\n### siteUrl\n\nYour website's base url. This gets prepended to all documents locations.\n\nType: `string`\n\nRequired: `true`\n\n### fileName\n\nDetermine the output filename for the sitemap.\n\nType: `string`\n\nDefault: `sitemap.xml`\n\nRequired: `false`\n\n### changefreq\n\nGets filled inside the sitemap in the tag `\u003cchangefreq\u003e`. Not added by default.\n\nType: `string`\n\nDefault: `undefined`\n\nValid Values: `['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never']`\n\nRequired: `false`\n\n**Note: any falsey value is also valid and will skip this xml tag**\n\n### priority\n\nGets filled inside the sitemap in the tag `\u003cpriority\u003e`. Not added by default.\n\nType: `string|function`\n\nDefault: `undefined`\n\nValid Values: `0.0` to `1.0`\n\nRequired: `false`\n\n**Note: any falsey (non-zero) value is also valid and will skip this xml tag**\n\nExample using a function as `priority`:\n\n\n```js\npriority: function(siteUrl, loc, entry) {\n    // Give pages inside root path (i.e. no slashes) a higher priority\n    return loc.split('/').length === 0 ? 1 : 0.5;\n}\n```\n\n### lastmod\n\nThe file last modified time.\n\n- If `null` then this plugin will try to get the last modified time from the stream vinyl file, or use `Date.now()` as lastmod.\n- If the value is not `null` - It will be used as lastmod.\n- When `lastmod` is a function, it is executed with the current file given as parameter. (Note: the function is expected to be sync).\n- A string can be used to manually set a fixed `lastmod`.\n\nType: `string|datetime|function`\n\nDefault: `null`\n\nRequired: `false`\n\nExample that uses git to get lastmod from the latest commit of a file:\n\n```js\nlastmod: function(file) {\n  var cmd = 'git log -1 --format=%cI \"' + file.relative + '\"';\n  return execSync(cmd, {\n    cwd: file.base\n  }).toString().trim();\n}\n```\n\n**Note: any falsey (other than null) value is also valid and will skip this xml tag**\n\n### newLine\n\nHow to join line in the target sitemap file.\n\nType: `string`\n\nDefault: Your OS's new line, mostly: `\\n`\n\nRequired: `false`\n\n### spacing\n\nHow should the sitemap xml file be spaced. You can use `\\t` for tabs, or `  ` with 2\nspaces if you'd like.\n\nType: `string`\n\nDefault: `    ` (4 spaces)\n\nRequired: `false`\n\n### noindex\n\nExclude pages from the sitemap when the `robots` meta tag is set to `noindex`. The plugin needs to be able to read the contents of the files for this to have an effect.\n\nType: `boolean`\n\nDefault: `false`\n\nRequired: `false`\n\n### images\n\nFor generate sitemap for images per page, just enable images flag to `true`\n\nType: `boolean`\n\nDefault: `undefined`\n\nRequired: `false`\n\n\n### mappings\n\nAn object to custom map pages to their own configuration.\n\nThis should be an array with the following structure:\n\nType: `array`\n\nDefault: `[]`\n\nRequired: `false`\n\nExample:\n\n```js\nmappings: [{\n    pages: [ 'minimatch pattern' ],\n    changefreq: 'hourly',\n    priority: 0.5,\n    lastmod: Date.now(),\n    getLoc(siteUrl, loc, entry) {\n        // Removes the file extension if it exists\n        return loc.replace(/\\.\\w+$/, '');\n    },\n    hreflang: [{\n        lang: 'ru',\n        getHref(siteUrl, file, lang, loc) {\n            return 'http://www.amazon.ru/' + file;\n        }\n    }]\n},\n//....\n]\n```\n\n- Every file will be matched against the supplied patterns\n- Only defined attributes for a matched file are applied.\n- Only the first match will apply, so consequent matches for the filename will not apply.\n- Possible attributes to set: `hreflang`, `changefreq`, `priority`, `loc` and `lastmod`.\n- All rules applying to [options](#options) apply to the attributes that can overridden.\n\n##### pages\n\nType: `array`\n\nRequired: `true`\n\nThis is an array with [minimatch](https://github.com/isaacs/minimatch) patterns to match the\nrelevant pages to override.\nEvery file will be matched against the supplied patterns.\n\nUses [multimatch](https://github.com/sindresorhus/multimatch) to match patterns against filenames.\n\nExample: `pages: ['home/index.html', 'home/see-*.html', '!home/see-admin.html']`\n\n##### hreflang\n\nMatching pages can get their `hreflang` tags set using this option.\n\nThe input is an array like so:\n\n```js\nhreflang: [{\n    lang: 'ru',\n    getHref: function(siteUrl, file, lang, loc) {\n        // return href src for the hreflang. For example:\n        return 'http://www.amazon.ru/' + file;\n    }\n}]\n```\n\n##### getLoc\n\nMatching pages can get their `loc` tag modified by using a function.\n\n```js\ngetLoc: function(siteUrl, loc, entry) {\n    return loc.replace(/\\.\\w+$/, '');\n}\n```\n\n#### verbose\n\nType: `boolean`\n\nRequired: `false`\n\nDefault: `false`\n\nIf true, will log the number of files that where handled.\n\n## Complementary plugins\n\n- [gulp-sitemap-files](https://github.com/adam-lynch/gulp-sitemap-files) - Get all files listed in a sitemap (Perhaps one generated from this plugin)\n\n## Thanks\n\nTo [grunt-sitemap](https://github.com/RayViljoen/grunt-sitemap) for the inspiration on writing this.\n\n## License\n\nMIT © [Gilad Peleg](https://www.giladpeleg.com)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgilad%2Fgulp-sitemap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgilad%2Fgulp-sitemap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgilad%2Fgulp-sitemap/lists"}