Git Product home page Git Product logo

grunt-assemble-sitemap's Introduction

grunt-assemble-sitemap NPM version NPM monthly downloads NPM total downloads Linux Build Status Windows Build Status

Sitemap plugin for Assemble

Table of Contents

Install

Install with npm:

$ npm install --save grunt-assemble-sitemap

Usage

Register the plugin in your assemble config:

assemble: {
  options: {
    plugins: ['grunt-assemble-sitemap', 'other/plugins/*']
  }
}

Visit the plugins docs for more info or for help getting started.

Options

See sitemaps.org for detail XML tag definitions.

dest

Type: String

Default: undefined

Sitemap destination. If not set, fallback to assemble destination.

homepage

Type: String

Default: homepage (from package.json)

Site URL

changefreq

Type: String

Default: weekly

How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page. Valid values are:

  • always
  • hourly
  • daily
  • weekly
  • monthly
  • yearly
  • never

priority

Type: Float

Default: 0.5

The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0. This value does not affect how your pages are compared to pages on other sites—it only lets the search engines know which pages you deem most important for the crawlers.

exclude

Type: Array

Default: ['404']

Pages to omit from the sitemap.

options: {
  sitemap: {
    exclude: ["foo", "bar"],
  },
  files: {
    ...
  }
}

relativedest

Type: String / Boolean

Default: false

Path to which the URLs in Sitemap and Robots should be relative to. true is equal to the destination path dest and false is equal to the root directory.

basename

Type: String Default: sitemap.xml

If you have a master sitemap that references sub-sitemaps, use this feature. For example static-sitemap.xml

robot

Type: Boolean

Default: true

Generate robots.txt from exclusions list.

pretty

Type: Boolean Default: false

When generating a sitemap with directory indexes, use pretty urls by removing index path segments from http://www.example.com/directory/index.html to to create http://www.example.com/directory/

Simple

To simplify might do something like:

assemble: {
  blog: {
    options: {
      plugins: ['grunt-assemble-sitemap'],
    },
    files: {
      './blog/': ['./templates/blog/*.hbs']
    }
  }
}

Result

./blog/sitemap.xml
./blog/robots.txt

Advanced

assemble: {
  blog: {
    options: {
      plugins: ['grunt-assemble-sitemap'],
      sitemap: {
        homepage: 'http://assemble.io',
            changefreq: 'daily',
            priority: '0.8',
            exclude: ['50x', 'foo'],
            robot: false
      }
    },
    files: {
      './blog/': ['./templates/blog/*.hbs']
    }
  }
}

Result

./blog/sitemap.xml

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Contributors

Commits Contributor
64 hariadi
11 doowb
7 rauberdaniel
7 hgoebl
2 jonschlinkert
1 quartzmo
1 jarrodconnolly
1 Melindrea
1 olegsmetanin

Release history

2017-03-16 v0.2.6

  • Add option.basename to specify the basename of the output file. Defaults to sitemap.xml.
  • Add option.pretty to remove index.html from paths.
  • Repo code clean up.

2014-05-31 v0.2.5

  • fix sitemap and robots not generated
  • relativedest can be a path now

2014-05-31 v0.2.4

  • added sitemap URL to robots.txt
  • added relativedest to options

2014-05-02 v0.2.3

  • fixes toc
  • Change docs to use verb

2014-03-25 v0.2.2

  • Change from plugin to middleware

2014-02-20 v0.2.1

  • fix option.robot was ignored and always true 0159123
  • (feat) add option.dest and use as output path
  • fix option.robot was ignored and always true
  • (feat) add option to overwrite changefreq per file
  • cosmetical changes (code formatting, naming, simplify)
  • (wip) enable globbing patterns for option.exclude

2014-02-04 v0.2.0

  • Generation of robots.txt will now respect the relativedest option.

2014-02-01 v0.1.9

  • Fix sitemap destination

2014-01-27 v0.1.8

  • Use external library
  • Get pages from assemble object

2014-01-02 v0.1.7

  • Add relativedest option

2013-12-11 v0.1.6

  • Fix plugin name in Usage Examples
  • Update deps

2013-11-27 v0.1.4

  • Updates dependencies to work with Grunt 0.4.2
  • [object Object]
  • Add TOC to docs

2013-10-19 v0.1.3

  • Fix sitemap and robots.txt generated on every folder
  • Update docs options:exclusions

2013-10-17 v0.1.2

  • Fix homepage

2013-10-16 v0.1.1

  • Add option to generate robots.txt
  • Change name to assemble-contrib.sitemap
  • Move to Assemble main repo

2013-09-30 v0.1.0

  • First commmit.
  • Add option to exclude

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Hariadi Hinta

License

Copyright © 2017, Hariadi Hinta. Released under the MIT License.


This file was generated by verb-generate-readme, v0.4.3, on March 17, 2017.

grunt-assemble-sitemap's People

Contributors

doowb avatar hariadi avatar hgoebl avatar jarrodconnolly avatar jonschlinkert avatar melindrea avatar olegsmetanin avatar quartzmo avatar rauberdaniel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-assemble-sitemap's Issues

Support target folder other than .

We generate the results of our webside to the directory dist/ and later copy the contents of that directory to the root of a web server.

That means the effective url of a index.html file located in the dist directory is http://my.site/index.html rather than http://my.site/dist/index.html.

Looking into the generated sitemap.xml, I see that the dist/ part is written into the <loc /> tag.
Is there an option to strip that part from the location tag?

Different priorities on sitemap pages

Hey guys, this is more a question

How can I assign different priorities to the pages listed in the sitemap lets say I want index to have 0.9 priority but I want contactus page to have 0.5? Is this possible? in the docs I only see a homepage: { ........, priority: 0.9,....} but that assigns the same priority to all pages...

regards

option.robot sets false but don't work .

i find a problem,

options: {
  sitemap: {
    robot: false
   }
 }

even though i set robot false, but it stil build robots.txt.
and i see sitemap.js line 29

options.robot = options.robot || true;

false || true == ture , so it doesn't work.

should be like this:

options.robot = options.robot || false;

and default is false

`relativedest` should accept string value

I think the relativedest should accept a string value (a path), to which the URLs should be relative to. Sometimes it’s not the root but also not the full destination path.

What do you think?
I’ll implement it, if this makes sense to you.

refactor

hey @hariadi! hope all is well, I'm about to publish a new assemble-sitemap, would you mind adding me and @doowb to npm? thanks!

Thoughts about robots.txt and exclusions

I'm not completely happy with the current options regarding robots.txt and exclusions, but maybe I just have unusual requirements or misunderstand something.

What we have:

    exclude: ['foo', 'bar']
    robot: true

This generates a sitemap without any file in any directory called foo.html or bar.html. And the robots.txt is pointing the bad bots to particular resources they shouldn't crawl.

First of all, I'd like exclusion patterns, e.g. error/**. Listing all filenames without directory name can be cumbersome and ambigous.

Next, robots.txt shouldn't list all the files, but enable to exclude paths.

BTW robots.txt could also point to the generated sitemap.xml. This could be generated as well.

With 127d160
my options for sitemap look like this:

    sitemap: {
        changefreq: 'weekly',
        exclude: ["**/blog/**", "**/error/**"],
        relativedest: true,
        dest: '<%= site.dest %>',
        robot: false
    }

(I exclude **/blog/** because it's almost empty and not functional yet.)
So I don't generate robots.txt and I can live without it, YMMV.

But we should think about this in advance, because we can run into upwards compatibility issues when exclude has to be changed somehow.

BTW is site.dest always present in assemble? Then sitemap-plugin wouldn't need it as option. (Sorry, I'm quite new to assemble, but I like it very much).

sitemap index

Would be nice to be able to generate a sitemap index: http://www.sitemaps.org/protocol.html#index

I've thought about doing this before, but I couldn't decide if it would be better to use an XML converter, or just plain old Handlebars templates. Just something to consider, it might be possible to make this plugin more powerful if you did a combination of the two.

Using handlebars templates might make it easier to build a sitemap index as well.

Nice work on this!

Moving to `grunt-assemble-sitemap`

@hariadi we'd like to move this code to grunt-assemble-sitemap and deprecating assemble-middleware-sitemap on npm. Let me know if you have any issues/questions/comments about this and we can discuss it.

There are some outstanding PRs and issues that may be resolved before moving. Let me know if you'd like to handle any of them.

Priority can’t be set in page template

I was trying to set the priority for some pages explicitly, since it doesn’t make sense so set them all to the same value. However, it didn’t have any effect.


---
title: Home
priority: 1.0

---

option for gzip compression

AFAIK most crawlers try to get sitemap.xml.gz, or am I wrong?

For this it would be nice if this plugin offered an option to create the gzipped version of sitemap.xml.

Of course there are workarounds, e.g. grunt-contrib-compress, so this is not high-prio.

robots.txt

Seems like it would make sense to have an option to automatically generate the robots.txt file as well. The plugin could use the exclusions to build the "do not crawl" list. What do you think?

Multi-target sitemap

Hello,

at the moment I run the command grunt assemble which has many targets.
However only the last target remains in the sitemap.

Is this how the plugin is intended to work?

I suppose you should create a writeStream when grunt is about run, and you write every time you encounter a page, then you close the stream when grunt ends its work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.