mapify-cli is a CLI tool for generating sitemap.xml files for various frontend frameworks such as Angular, React, Vue, and more. It simplifies the creation of sitemaps by using a configuration file and automatically detects changes in your project files to update the lastmod attribute.
- Framework Agnostic: Works with Angular, React, Vue, and other frontend frameworks.
- Automatic Last Modified Dates: Detects the latest modifications of component files to update the
lastmodattribute in your sitemap. - Customizable Config: Provides options to configure default change frequencies, priorities, and more.
- Multiple Builds Support: Handles multiple build outputs seamlessly. You can specify different output paths for various builds like SSR and serverless.
- Force Option: Allows you to bypass Git detection for
lastmodupdates.
To install mapify-cli, run:
npm install -g mapify-cli--init: Initializes a sample config file (mapify.config.js).--config <path>: Uses a custom configuration file.--generate: Generates thesitemap.xmlfile based on the config.
To generate the sitemap.xml, use:
npx mapify-cli --generateCreate a configuration file (mapify.config.js) in your project root. The configuration should look like this:
/** @type {import('mapify-cli').MapifyConfig} */module.exports={baseUrl: "http://example.com",// requiredoutputPaths: ['./dist/angular-ui/browser','./dist/angular-ui-serverless/browser'],// requiredpages: [{path: '/',// requiredpriority: 1,// requiredchangeFreq: 'weekly',// (optional) default = monthlycomponentPath: './src/app/pages/home/**'// (optional)},{path: '/about',priority: 0.8,componentPath: './src/app/pages/about/**'},{path: '/contact',priority: 0.8,componentPath: './src/app/pages/contact/**'},{path: '/login',priority: 0.9,changeFreq: 'weekly',componentPath: './src/app/pages/login/**'}],defaultChangeFreq: 'monthly',// optionaldefaultPriority: 0.5,// optionalforceLastModificationDate: false// optional};baseUrl(string): The base URL of your site.outputPaths(string[]): Array of output paths where thesitemap.xmlwill be saved. Supports multiple builds, such as SSR and serverless builds.pages(IPage[]): Array of page configurations.path(string): The URL path of the page.priority(number): The priority of the page (0.0 to 1.0).changeFreq(ChangeFreq): Optional. How frequently the page is likely to change (e.g., 'daily', 'weekly'). Defaults todefaultChangeFreq.componentPath(string): Optional. Path to the components used to detect the last modified date.
defaultChangeFreq(ChangeFreq): Default change frequency for all pages.defaultPriority(number): Default priority for all pages.forceLastModificationDate(boolean): If true, skips Git detection forlastmodand uses the current date.
To automate sitemap generation using GitHub Actions, add the following workflow to your .github/workflows/ directory:
name: Generate Sitemapon:
push:
branches:
- mainjobs:
generate-sitemap:
runs-on: ubuntu-lateststeps:
- name: Checkout Codeuses: actions/checkout@v4with:
fetch-depth: 0
- name: Generate Sitemaprun: npx mapify-cli --generateThis project is licensed under the MIT License.
We welcome contributions to improve mapify-cli. Please see the CONTRIBUTING.md file for more information.
For any issues or feature requests, please open an issue on the GitHub repository.
We are committed to providing a welcoming and inclusive environment for all contributors. Please review our Code of Conduct to understand our community standards and expectations.