Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
golang.org/x/sync v0.19.0
golang.org/x/term v0.39.0
mvdan.cc/sh/moreinterp v0.0.0-20260120230322-19def062a997
mvdan.cc/sh/v3 v3.12.0
mvdan.cc/sh/v3 v3.12.1-0.20260124232039-e74afc18e65b
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mvdan.cc/sh/moreinterp v0.0.0-20260120230322-19def062a997 h1:3bbJwtPFh98dJ6lxRdR3eLHTH1CmR3BcU6TriIMiXjE=
mvdan.cc/sh/moreinterp v0.0.0-20260120230322-19def062a997/go.mod h1:Qy/zdaMDxq9sT72Gi43K3gsV+TtTohyDO3f1cyBVwuo=
mvdan.cc/sh/v3 v3.12.0 h1:ejKUR7ONP5bb+UGHGEG/k9V5+pRVIyD+LsZz7o8KHrI=
mvdan.cc/sh/v3 v3.12.0/go.mod h1:Se6Cj17eYSn+sNooLZiEUnNNmNxg0imoYlTu4CyaGyg=
mvdan.cc/sh/v3 v3.12.1-0.20260124232039-e74afc18e65b h1:PUPnLxbDzRO9kg/03l7TZk7+ywTv7FxmOhDHOtOdOtk=
mvdan.cc/sh/v3 v3.12.1-0.20260124232039-e74afc18e65b/go.mod h1:mencVHx2sy9XZG5wJbCA9nRUOE3zvMtoRXOmXMxH7sc=
24 changes: 19 additions & 5 deletions website/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,10 @@ export default defineConfig({
// Open Graph
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:site_name', content: taskName }],
['meta', { property: 'og:title', content: taskName }],
['meta', { property: 'og:description', content: taskDescription }],
['meta', { property: 'og:image', content: ogImage }],
['meta', { property: 'og:url', content: ogUrl }],
// Twitter Card
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['meta', { name: 'twitter:site', content: '@taskfiledev' }],
['meta', { name: 'twitter:title', content: taskName }],
['meta', { name: 'twitter:description', content: taskDescription }],
['meta', { name: 'twitter:image', content: ogImage }],
[
'meta',
Expand Down Expand Up @@ -96,6 +91,15 @@ export default defineConfig({
.replace(/index$/, '')}`
head.push(['link', { rel: 'canonical', href: canonicalUrl }])

// Dynamic Open Graph and Twitter meta tags
const pageTitle = pageData.frontmatter.title || pageData.title || taskName
const pageDescription = pageData.frontmatter.description || pageData.description || taskDescription
head.push(['meta', { property: 'og:title', content: `${pageTitle} | Task` }])
head.push(['meta', { property: 'og:description', content: pageDescription }])
head.push(['meta', { property: 'og:url', content: canonicalUrl }])
head.push(['meta', { name: 'twitter:title', content: `${pageTitle} | Task` }])
head.push(['meta', { name: 'twitter:description', content: pageDescription }])

// Noindex pour 404
if (pageData.relativePath === '404.md') {
head.push(['meta', { name: 'robots', content: 'noindex, nofollow' }])
Expand Down Expand Up @@ -200,6 +204,16 @@ export default defineConfig({

sidebar: {
'/blog/': [
{
text: '2026',
collapsed: false,
items: [
{
text: 'New `if:` Control and Variable Prompt',
link: '/blog/if-and-variable-prompt'
}
]
},
{
text: '2025',
collapsed: false,
Expand Down
126 changes: 126 additions & 0 deletions website/src/blog/if-and-variable-prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
title: New `if:` Control and Variable Prompt
description: Introduction of the `if:` control and required variable prompts.
author: vmaerten
date: 2026-01-24
outline: deep
---

# New `if:` control and interactivity support

<AuthorCard :author="$frontmatter.author" />

The [v3.47.0][release] release is here, and it brings two exciting new features
to Task. Let's take a closer look at them!

## The New `if:` Control

This first feature is simply the second most upvoted issue of all time (!) with
58 :thumbsup:s (!!) at the time of writing.

It introduces the `if:` control, which allow you to conditionally skip the
execution of certain tasks and proceeding. `if:` can be set on a task-level or
command-level, and can be either a Bash command or a Go template expression.

Let me show a couple of examples.

Task-level with Bash expression:

```yaml
version: '3'

tasks:
deploy:
if: '[ "$CI" = "true" ]'
cmds:
- echo "Deploying..."
- ./deploy.sh
```

Command-level with Go template expression:

```yaml
version: '3'

tasks:
conditional:
vars:
ENABLE_FEATURE: "true"
cmds:
- cmd: echo "Feature is enabled"
if: '{{eq .ENABLE_FEATURE "true"}}'
- cmd: echo "Feature is disabled"
if: '{{ne .ENABLE_FEATURE "true"}}'
```

For more details, please check out the [documentation][if-docs].
The [examples][if-examples] from the test suite may be useful too.

::: info

We had similar functionality before, but nothing that perfectly fits this use
case. There were [`sources:`][sources] and [`status:`][status], but those were
meant to check if a task was up-to-date, and [`preconditions:`][preconditions],
but this would halt the execution of the task instead of skipping it.

:::

## Prompt for Required Variables

For backward-compatibility reasons, this feature is disabled by default.
To enable it, either pass `--interactive` flag or add `interactive: true` to
your `.taskrc.yml`.

Once you do that, Task will basically starting prompting you in runtime for any
required variables. In the example below, `NAME` will be prompted at runtime:

```yaml
version: '3'

tasks:
# Simple text input prompt
greet:
desc: Greet someone by name
requires:
vars:
- NAME
cmds:
- echo "Hello, {{.NAME}}!"
```

If a given variable has an enum, Task will actually show a selection menu so you
can choose the right option instead of typing:

```yaml
version: '3'

tasks:
# Enum selection (dropdown menu)
deploy:
desc: Deploy to an environment
requires:
vars:
- name: ENVIRONMENT
enum: [dev, staging, prod]
cmds:
- echo "Deploying to {{.ENVIRONMENT}}..."
```

Once again, check out the [documentation][prompt-docs] for more details, and the
[prompt examples][prompt-examples] from the test suite.

## Feedback

Let's us know if you have any feedback! You can find us on our
[Discord server][discord].

[release]: https://github.com/go-task/task/releases/tag/v3.47.0
[vmaerten]: https://github.com/vmaerten
[sources]: https://taskfile.dev/docs/guide#by-fingerprinting-locally-generated-files-and-their-sources
[status]: https://taskfile.dev/docs/guide#using-programmatic-checks-to-indicate-a-task-is-up-to-date
[preconditions]: https://taskfile.dev/docs/guide#using-programmatic-checks-to-cancel-the-execution-of-a-task-and-its-dependencies
[if-docs]: https://taskfile.dev/docs/guide#conditional-execution-with-if
[if-examples]: https://github.com/go-task/task/blob/main/testdata/if/Taskfile.yml
[prompt-docs]: https://taskfile.dev/docs/guide#prompting-for-missing-variables-interactively
[prompt-examples]: https://github.com/go-task/task/blob/main/testdata/interactive_vars/Taskfile.yml
[discord]: https://discord.com/invite/6TY36E39UK
9 changes: 9 additions & 0 deletions website/src/blog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ title: Blog
description: Latest news and updates from the Task team
---

<BlogPost
title="New `if:` Control and Variable Prompt"
url="/blog/if-and-variable-prompt"
date="2026-01-24"
author="vmaerten"
description="The v3.47.0 release is here, and it brings two exciting new features to Task. Let's take a closer look at them!"
:tags="['new-features', 'variables']"
/>

<BlogPost
title="Announcing Built-in Core Utilities for Windows"
url="/blog/windows-core-utils"
Expand Down
Loading