Question: I have a step defintion template, that I intend to use within build pipelines. 
The step definition's location is not under the same folder as the build pipeline itself. 

During the validation of the pipeline, AzureDevops considers build pipeline's location as the root location. This is appended to the path of the reference

consider the following example of code hierarchy

```
 azure
   |----products
           |----resource-type1
                        |----step-def.yaml
           |----resource-type2
                        |----step-def.yaml
   |----solutions
           |----solution1
                    |----local-step-def.yaml
                    |----build.yaml
           |----solution2
                    |----build.yaml

```

Following works when the build.yaml is as below

```
jobs:
- job: Linux
  pool:
    vmImage: 'ubuntu-16.04'
  steps:
  - template: solution1/local-step-def.yml

```

If you change the template reference as below, it does not work

```
  - template: ../products/resource-type1/step-def.yml

```

When validation is done on the pipeline, azure-devops maps to

```
# <path-of-the-build-pipeline>/<template-ref>
azure/solutions/solution1/<template-reference>

```

Here is the documentation, <https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#step-re-use> 

So how can I map to the step-def.yaml file that lives in the products folder hierarchy?

Answer: 
I found only one solution to actually do that. You can reference the parent directory by using an absolute path. The key was to populate the root path using a system variable. The solution for your example:

```
jobs:
- job: Linux
  pool:
    vmImage: 'ubuntu-16.04'
  steps:
  - template: ${{variables['System.DefaultWorkingDirectory']}}/products/resource-type1/step-def.yml

```
you can try to use [repositoryResource](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#using-other-repositories) syntax despite the fact that it is the same reposstory, like

```
resources:
  repositories:
    - repository: pckgtemplates #resource name to be used in the build pipeline
      type: git #Azure git 
      name: packages/packagesRepo

jobs:
- template: templates\version.file.yml@pckgtemplates  
  parameters:
    versionFile: versionFile

```

`- template: templates\version.file.yml@pckgtemplates` this references `version.file.yml` template in the `templates` folder of the `pckgtemplates` resource. 

And `pckgtemplate` resource references to the `packages` project of the current organization and `packagesRepo` repository.

Using this you can define resource that references the same project and `products/resource-type1/step-def.yml` template