Give a warning if two components have the same handle/url #188

risker opened this Issue Dec 7, 2016 · 3 comments


None yet

3 participants

risker commented Dec 7, 2016

This is a problem with a large system. I have come across two separate issues:

  1. We typically have an examples folder in the component folder, and some examples under separate components have the same name.
  2. We manage view prototypes for multiple environments, and, for example, every environment has a "front-page".

Both of these result in the same handle and url.

I can (sort-of) fix these issues by specifying a prefix in a collection/component config, but first I would need to now where I'm having an overwrite issue without manually going through my component tree.

The second possible solution would be to automatically prefix certain collections with the collection name (eg if I have nested collections I should only set prefix: true on the first level collection) and all duplicate url issues for that collection are solved.


@risker I think some sort of warning in the CLI when fractal comes across two duplicate handles is definitely a good idea to have and should be pretty easy to add in.

In the meantime, and similar to my answer to #189 if you want to do a 'check' on all your components to see if any have any duplicate handles you could use a custom command like the following:

fractal.cli.command('check-handles', function(opts, done){
    fractal.load().then(src => {
        const used = [];
        let error = false;
        for (let comp of fractal.components.flatten()) {
            const handle = comp.handle;
            const previous = used.filter(u => u.handle === handle);
            if (previous.length) {
                error = true;
                let paths = => p.path);
                this.console.error(`Duplicate handle @${handle} - used in
 - ${paths.join('\n - ')}
                handle: handle,
                path: comp.viewPath
        if (!error) {
            this.console.success('No duplicate handles found!');

Add that into your fractal.js file and then you should be able to run it using fractal check-handles to identify any duplicate handle issues.


This is a bit awesome :)


I'm going to close this issue now - @risker if you have any probs with the above feel free to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment