<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Jean-Yves Gastaud blog</title>
    <link>https://gastaud.io/en/</link>
    <description>Recent content on Jean-Yves Gastaud blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-en</language>
    <lastBuildDate>Sat, 27 Nov 2021 16:14:35 +0100</lastBuildDate>
    
        <atom:link href="https://gastaud.io/en/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Install and configure Renovate Bot on GitLab CE</title>
      <link>https://gastaud.io/en/article/gitlab-renovatebot/</link>
      <pubDate>Sat, 27 Nov 2021 16:14:35 +0100</pubDate>
      
      <guid>https://gastaud.io/en/article/gitlab-renovatebot/</guid>
      
        <description>&lt;p&gt;&lt;a href=&#34;https://renovatebots.com&#34;&gt;Renovate Bot&lt;/a&gt; is a tool to control the versions of dependencies of your projects.&lt;/p&gt;
&lt;p&gt;It can be compared to the &lt;a href=&#34;https://github.com/dependabot&#34;&gt;Dependabot&lt;/a&gt; project which is available on GitHub.&lt;/p&gt;
&lt;p&gt;In this article, we will explore how to install and configure Renovate to run on a Gitlab CE instance.&lt;/p&gt;
&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;In order to follow the initialization process you must be able to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create groups and projects&lt;/li&gt;
&lt;li&gt;Have access or install at least 1 GitLab Runner with a docker executor&lt;/li&gt;
&lt;li&gt;Have a GitHub account (even if we are going to use GitLab, it will be used to get the release notes of the projects)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;initialization&#34;&gt;Initialization&lt;/h2&gt;
&lt;h3 id=&#34;project-structure&#34;&gt;Project structure&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Create a &lt;code&gt;Renovate&lt;/code&gt; project group&lt;/li&gt;
&lt;li&gt;Create 2 projects in the group
&lt;ul&gt;
&lt;li&gt;a &lt;code&gt;renovate-config&lt;/code&gt; project which will contain configuration files that can be shared with all GitLab projects;&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;renovate-runner&lt;/code&gt; project which will contain the configurations to dedicate to the Renovate container.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;gitab-user&#34;&gt;Gitab user&lt;/h3&gt;
&lt;p&gt;As the name of the project indicates (Renovate&lt;strong&gt;Bot&lt;/strong&gt;) we will have to create a user account representing our Bot.&lt;/p&gt;
&lt;p&gt;For our example, we will call it &lt;code&gt;Renovate Bot &amp;lt;renovatebot@example.com&amp;gt;&lt;/code&gt; and the username &lt;code&gt;renovatebot&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This user will be used for 2 things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;merge requests, commits&amp;hellip; will be created by the Bot ;&lt;/li&gt;
&lt;li&gt;restrict renovate&amp;rsquo;s rights to browse only those projects on which it is explicitly invited.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;renovate-runner-project-configuration&#34;&gt;Renovate-runner project configuration&lt;/h2&gt;
&lt;p&gt;We will start by working on the runner part. Let&amp;rsquo;s go to the &lt;code&gt;renovate-runner&lt;/code&gt; project we created earlier.&lt;/p&gt;
&lt;h3 id=&#34;creation-of-user-tokens-pat--personal-access-token&#34;&gt;Creation of user tokens (PAT : Personal Access Token)&lt;/h3&gt;
&lt;h4 id=&#34;gitlab&#34;&gt;GitLab&lt;/h4&gt;
&lt;p&gt;On your GitLab instance, log in with the &lt;code&gt;renovatebot&lt;/code&gt; account created earlier.&lt;/p&gt;
&lt;p&gt;We&amp;rsquo;ll create an Access Token via your user profile (/-/profile/personal_access_tokens).&lt;/p&gt;
&lt;p&gt;Name the token whatever you like (&lt;code&gt;renovatebot&lt;/code&gt; for example) and choose the following scopes as &lt;a href=&#34;https://docs.renovatebot.com/getting-started/running/#gitlab&#34;&gt;indicated in the documentation&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;read_user&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;api&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;write_repository&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Copy the token and go back to the &lt;code&gt;renovate-runner&lt;/code&gt; project, in the CI/CD Settings (menu &lt;code&gt;Settings&lt;/code&gt; &amp;gt; &lt;code&gt;CI/CD&lt;/code&gt; &amp;gt; &lt;code&gt;Variables&lt;/code&gt;)&lt;/p&gt;
&lt;p&gt;and create a new variable named &lt;code&gt;RENOVATE_TOKEN&lt;/code&gt; with the retrieved token value.&lt;/p&gt;
&lt;h4 id=&#34;github&#34;&gt;GitHub&lt;/h4&gt;
&lt;p&gt;In order to be able to retrieve release notes from projects and not be subject to the limitations of the GitHub API, we will need to create a GitHub and create a &lt;a href=&#34;https://docs.renovatebot.com/getting-started/running/#githubcom-token-for-release-notes&#34;&gt;Personal Access Token&lt;/a&gt; there.&lt;/p&gt;
&lt;p&gt;Copy the token and go back to the &lt;code&gt;renovate-runner&lt;/code&gt; project, in the CI/CD Settings (menu &lt;code&gt;Settings&lt;/code&gt; &amp;gt; &lt;code&gt;CI/CD&lt;/code&gt; &amp;gt; &lt;code&gt;Variables&lt;/code&gt;)&lt;/p&gt;
&lt;p&gt;and create a new variable named &lt;code&gt;GITHUB_COM_TOKEN&lt;/code&gt; with the value of the recovered token.&lt;/p&gt;
&lt;h3 id=&#34;our-gitlab-ciyml-file&#34;&gt;Our &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;image: renovate/renovate:29	

variables:
  RENOVATE_BASE_DIR: $CI_PROJECT_DIR/renovate
  RENOVATE_GIT_AUTHOR: Renovate Bot &amp;lt;renovatebot@exemple.com&amp;gt;
  RENOVATE_OPTIMIZE_FOR_DISABLED: &#39;true&#39;
  RENOVATE_REPOSITORY_CACHE: &#39;true&#39;
  LOG_LEVEL: debug


cache:
  key: ${CI_COMMIT_REF_SLUG}-renovate
  paths:
    - $CI_PROJECT_DIR/renovate

renovate:
  stage: deploy
  resource_group: production
  only:
    - schedules
  script:
    - renovate $RENOVATE_EXTRA_FLAGS
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Renovate offers most of these configurations as environment variables.
However, to be able to use the bot in other contexts than GitLab (a manual launch for example), I only kept the GitLab specific parameters in the &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;The rest of the configurations are in the &lt;code&gt;config.js&lt;/code&gt; file that we&amp;rsquo;ll look at right now. ⬇️&lt;/p&gt;
&lt;h3 id=&#34;renovate-configuration-file&#34;&gt;Renovate configuration file&lt;/h3&gt;
&lt;p&gt;Renovate is based on a configuration file &lt;code&gt;config.js&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It defines the Git platform to use, the &lt;a href=&#34;https://docs.renovatebot.com/self-hosted-configuration/&#34;&gt;configuration options&lt;/a&gt; of the runner and the &lt;a href=&#34;https://docs.renovatebot.com/config-presets/&#34;&gt;configuration profiles (Config Presets)&lt;/a&gt; which will be applied for all the projects &lt;code&gt;onboardingConfig&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;module.exports = {
        endpoint: &#39;https://[url of gitlab]/api/v4/&#39;,
        platform: &#39;gitlab&#39;,
        persistRepoData: true,
        logLevel: &#39;debug&#39;,
        onboardingConfig: {
                &#39;extends&#39;: [
                        &amp;quot;local&amp;gt;groups/subgroups/renovate/renovate-config&amp;quot;
                ],
        },
        autodiscover: true,
};
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;recurring-task&#34;&gt;Recurring task&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;CI/CD menu &amp;gt; Schedules&lt;/li&gt;
&lt;li&gt;Create a new scheduled task with the frequency you want (I made the choice, totally arbitrary, to run the analysis twice a day) and to trigger.&lt;/li&gt;
&lt;li&gt;Save&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;configuration-of-default-configurations&#34;&gt;Configuration of default configurations&lt;/h2&gt;
&lt;p&gt;In the &lt;code&gt;renovate-config&lt;/code&gt; project we will create a simple &lt;code&gt;renovate.json&lt;/code&gt; file which will be the one searched by default by the &lt;code&gt;config.json&lt;/code&gt; file and in particular the line &lt;code&gt;&amp;quot;local&amp;gt;groups/subgroups/renovate/renovate-config&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Here are the choices I made:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt; {
  &amp;quot;$schema&amp;quot;: &amp;quot;https://docs.renovatebot.com/renovate-schema.json&amp;quot;,
  &amp;quot;packageRules&amp;quot;: [
    {
      &amp;quot;depTypeList&amp;quot;: [ &amp;quot;devDependencies&amp;quot;, &amp;quot;require-dev&amp;quot; ],
      &amp;quot;updateTypes&amp;quot;: [ &amp;quot;patch&amp;quot;, &amp;quot;minor&amp;quot;, &amp;quot;digest&amp;quot;],
      &amp;quot;groupName&amp;quot;: &amp;quot;devDependencies (non-major)&amp;quot;
    }
  ],
  &amp;quot;extends&amp;quot;: [
    &amp;quot;config:base&amp;quot;,
    &amp;quot;:preserveSemverRanges&amp;quot;,
    &amp;quot;:dependencyDashboard&amp;quot;,
    &amp;quot;:rebaseStalePrs&amp;quot;,
    &amp;quot;:enableVulnerabilityAlertsWithLabel(&#39;security&#39;)&amp;quot;,
    &amp;quot;group:recommended&amp;quot;
  ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;packageRules&lt;/code&gt; allows to create new groupings. In our case, this allows us to have a single Merge Request containing all the development dependencies of the project when they are not major.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;Extends&lt;/code&gt; allows us to define the rules/configs presets that we want to activate. In particular, we activate the &lt;a href=&#34;https://docs.renovatebot.com/key-concepts/dashboard/&#34;&gt;Dependency Dashboard&lt;/a&gt; which allows us to follow in a ticket the status of all available updates and/or current MRs and various &lt;a href=&#34;https://docs.renovatebot.com/presets-group/&#34;&gt;Group Presets&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;activate-the-bot-for-projects&#34;&gt;Activate the bot for projects&lt;/h2&gt;
&lt;p&gt;With these configurations, each project that wants to activate the bot has only 4 steps to follow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add the user &lt;code&gt;renovatebot&lt;/code&gt; on the project, with at least a &lt;code&gt;contributor&lt;/code&gt; right&lt;/li&gt;
&lt;li&gt;Enable the &lt;code&gt;issues&lt;/code&gt; for the &lt;code&gt;dependency Dashboard&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Enable &lt;code&gt;merge requests&lt;/code&gt; for first with a 1st Merge Request to create the renovate configuration, then the MRs associated with the updates to apply.&lt;/li&gt;
&lt;li&gt;Refine the Renovate configurations according to the specificities of your project&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And that&amp;rsquo;s it 🍾&lt;/p&gt;
&lt;p&gt;We now have a Renovate bot that runs regularly and will update all the repositories it has access to.&lt;/p&gt;</description>
      
    </item>
    
    <item>
      <title>Sorting tags from a Git repo using semantic versioning</title>
      <link>https://gastaud.io/en/article/git-sort-tags-semantic-version/</link>
      <pubDate>Mon, 20 Sep 2021 23:10:00 +0200</pubDate>
      
      <guid>https://gastaud.io/en/article/git-sort-tags-semantic-version/</guid>
      
        <description>&lt;p&gt;A quick post today to tell you about a recent discovery in Git&amp;rsquo;s sorting functions and tags based on &lt;a href=&#34;https://semver.org/&#34;&gt;semantic versioning&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By default, if you run the &lt;code&gt;git tag -l&lt;/code&gt; command, Git will do an alphabetical sort.&lt;/p&gt;
&lt;p&gt;However, this sorting gives confusing results when the tags use semantic versioning notation.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;git tag -l
v2.6.1
v2.6.10
v2.6.11
v2.6.12
v2.6.2
v2.6.3
v2.6.4
v2.6.5
v2.6.6
v2.6.7
v2.6.8
v2.6.9
v2.7.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Notice here the sequence &lt;code&gt;v2.6.10&lt;/code&gt;, &lt;code&gt;v2.6.11&lt;/code&gt; and &lt;code&gt;v2.6.12&lt;/code&gt; which is interposed between version &lt;code&gt;v2.6.1&lt;/code&gt; and &lt;code&gt;v2.6.2&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To solve this problem, it is possible to use the &lt;code&gt;--sort&lt;/code&gt; function with the &lt;code&gt;version&lt;/code&gt; attribute in Git.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;git tag --sort&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;version:refname
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will display the sorted results consistently:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;git tag --sort&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;version:refname
v2.6.1
v2.6.2
v2.6.3
v2.6.4
v2.6.5
v2.6.6
v2.6.7
v2.6.8
v2.6.9
v2.6.10
v2.6.11
v2.6.12
v2.7.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      
    </item>
    
    <item>
      <title>Upgrade Buildx in Docker CLI</title>
      <link>https://gastaud.io/en/article/docker-buildx-upgrade/</link>
      <pubDate>Sat, 02 May 2020 14:29:42 +0200</pubDate>
      
      <guid>https://gastaud.io/en/article/docker-buildx-upgrade/</guid>
      
        <description>&lt;p&gt;Docker CLI, since version 19.03 includes the &lt;a href=&#34;https://github.com/docker/buildx&#34;&gt;buildx&lt;/a&gt; plugin to extend the build functions of Docker based on &lt;a href=&#34;https://github.com/moby/buildkit&#34;&gt;Buildkit&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Among the main points that Buildkit brings are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;parallel resolution of dependencies&lt;/li&gt;
&lt;li&gt;better cache management (import/export, resolution)&lt;/li&gt;
&lt;li&gt;ability to distribute workloads&lt;/li&gt;
&lt;li&gt;run without root privileges&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And so, as mentioned above, buildkit is now included in docker CLI.
Problem, the available and pre-packaged version is not up to date with the latest developments.&lt;/p&gt;
&lt;p&gt;If you want to take advantage of the latest evolutions,
you will need to update.&lt;/p&gt;

&lt;div class=&#34;shortcode-notice info&#34;&gt;
  &lt;div class=&#34;shortcode-notice-title info&#34;&gt;
    
      buildx version
    
  &lt;/div&gt;
  &lt;p&gt;This tutorial uses buildx version &lt;strong&gt;0.4.1&lt;/strong&gt;.&lt;br&gt;
Remember to check the latest version number before copying and pasting the instructions.&lt;/p&gt;

&lt;/div&gt;

&lt;h2 id=&#34;the-steps&#34;&gt;The steps&lt;/h2&gt;
&lt;p&gt;Check the existence of the &lt;code&gt;~/.docker/cli-plugins&lt;/code&gt; directory.
If it doesn&amp;rsquo;t exist, create the&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;mkdir ~/.docker/cli-plugins
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Download the latest buildx version from the &lt;a href=&#34;https://github.com/docker/buildx/releases&#34;&gt;Buildx release page on Github&lt;/a&gt; or directly from your terminal.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;wget -O ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Set execution rights on the binary: &lt;code&gt;chmod +x ~/.docker/cli-plugins/docker-buildx&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;and voila!&lt;/p&gt;
&lt;p&gt;We just have to check if the buildx version is now the expected one.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;docker buildx version
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you want buildx to become the default builder of Docker CLI&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;docker builx install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;demo&#34;&gt;Demo&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://asciinema.org/a/aWtsg3uCTb2wbEeZHh79c2ntS&#34;&gt;&lt;img src=&#34;https://asciinema.org/a/aWtsg3uCTb2wbEeZHh79c2ntS.svg&#34; alt=&#34;asciicast&#34;&gt;&lt;/a&gt;&lt;/p&gt;
</description>
      
    </item>
    
    <item>
      <title>Azure-cli, activate autocomplete on Zsh</title>
      <link>https://gastaud.io/en/article/azure-cli-autocomplete/</link>
      <pubDate>Tue, 26 Nov 2019 23:35:18 +0100</pubDate>
      
      <guid>https://gastaud.io/en/article/azure-cli-autocomplete/</guid>
      
        <description>&lt;p&gt;Out of the box, Azure-cli doesn&amp;rsquo;t have autocomplete activated in Zsh and Oh-My-Zsh framework doesn&amp;rsquo;t have plugin available natively.&lt;/p&gt;
&lt;p&gt;However, Azure-cli comes with an autocomplete script that should be located in &lt;code&gt;bash_completion.d&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;In my setup, using Ubuntu 18.04, I found the &lt;code&gt;azure-cli&lt;/code&gt; script in &lt;code&gt;/etc/bash_completion.d/&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;Now we just need to load the autocomplete script inside our &lt;code&gt;~/.zshrc&lt;/code&gt; with the following line:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;source /etc/bash_completion.d/azure-cli
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Save and reload your terminal. Done.&lt;/p&gt;
&lt;h3 id=&#34;additional-notes&#34;&gt;Additional notes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;If you encounter an error when restarting, you may have to add that line before the script loading to ensure cross compatibility between bash and zsh script&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;autoload -U +X bashcompinit &amp;amp;&amp;amp; bashcompinit
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Looking at different blog post, you may find that the script is called &lt;code&gt;az&lt;/code&gt;, not &lt;code&gt;azure-cli&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;According to the directory I found it, the script was natively loaded if I use bash shell. If you use bash and doesn&amp;rsquo;t have autocomplete activate, you probably have to search for &lt;code&gt;azure-cli&lt;/code&gt; or &lt;code&gt;az&lt;/code&gt; script and load it to your &lt;code&gt;~/.bashrc&lt;/code&gt; file.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</description>
      
    </item>
    
    <item>
      <title>GoHugo - Generate alternative images that can be used in the homepage</title>
      <link>https://gastaud.io/en/article/hugo-homepage-images-processing/</link>
      <pubDate>Thu, 11 Apr 2019 16:51:22 +0200</pubDate>
      
      <guid>https://gastaud.io/en/article/hugo-homepage-images-processing/</guid>
      
        <description>&lt;p&gt;Translate from French on &lt;a href=&#34;https://dev.to/jygastaud/gohugo-generate-image-declinations-that-can-be-used-as-a-home-page-530j&#34;&gt;dev.to&lt;/a&gt; and backport here.&lt;/p&gt;
&lt;p&gt;GoHugo, since version 0.32, is able to manage &lt;a href=&#34;https://gohugo.io/about/new-in-032/#page-resources&#34;&gt;dedicated one-page resources&lt;/a&gt;
as well as to generate &lt;a href=&#34;https://gohugo.io/about/new-in-032/#image-processing&#34;&gt;image declinations&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This feature is particularly useful for automatically managing responsible declinations of these images and using them in a template or shortcode.&lt;/p&gt;
&lt;p&gt;It works perfectly when you are in a content.&lt;/p&gt;
&lt;h2 id=&#34;so-whats-the-problem&#34;&gt;So what&amp;rsquo;s the problem?&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s assume that we want to use responsible images on the homepage of our site.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The home page is not part of a section or bundle and therefore does not have access to resources&lt;/li&gt;
&lt;li&gt;Files placed in the &lt;code&gt;static&lt;/code&gt; directory are not treated as resources by Hugo&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It will therefore be necessary to manage &amp;ldquo;by hand&amp;rdquo;, the declination of these images and include them manually in our template.&lt;/p&gt;
&lt;p&gt;To simplify, we have the following aborescence:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;.
| content
| | | _index.md
| layouts
| | | index.html
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;what-but-i-have-too-many-images-to-decline-and-the-content-changes-often&#34;&gt;What? But I have too many images to decline and the content changes often?!&lt;/h2&gt;
&lt;p&gt;To automate the generation process, we will use the &lt;a href=&#34;https://gohugo.io/news/0.35-relnotes/&#34;&gt;Headless Bundles&lt;/a&gt; introduced in version 0.35.&lt;/p&gt;
&lt;p&gt;This new type of bundle allows you to manage content that will not produce a full page when rendered by Hugo.&lt;/p&gt;
&lt;p&gt;It is therefore convenient to use it to manage blocks, messages&amp;hellip; which are then injected into the pages.&lt;/p&gt;
&lt;p&gt;By using this type of bundle and combining it with the image generation functionality, we will be able to automatically obtain our various image declinations.&lt;/p&gt;
&lt;p&gt;We will follow the following steps.&lt;/p&gt;
&lt;h4 id=&#34;creating-a-new-bundle-headless-img&#34;&gt;Creating a new bundle &lt;code&gt;headless-img&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;We will now have the following content tree structure:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;.
| content
| | | _index.md
| | | headless-img
| | | | | images
| | | | | | my_image.png
| | | | index.md
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The file &lt;code&gt;headless-img/index.md&lt;/code&gt; will contain&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-markdown&#34; data-lang=&#34;markdown&#34;&gt;+++
headless = true
title = &amp;#34;homepage images&amp;#34;
+++

{{&amp;lt; &lt;span style=&#34;color:#f92672&#34;&gt;imghp&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;images/mon_image.png&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;alt&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A nice image for our homepage&amp;#34;&lt;/span&gt; &amp;gt;}}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So we have created here a &lt;code&gt;headless&lt;/code&gt; resource that will call a hugo shortcode named &lt;code&gt;imghp&lt;/code&gt; and that takes a path and an alternative text as parameters.&lt;/p&gt;
&lt;h4 id=&#34;creating-the-shortcode&#34;&gt;Creating the shortcode&lt;/h4&gt;
&lt;p&gt;In the &lt;code&gt;layouts/shortcodes&lt;/code&gt; aborescence we will create a new file named &lt;code&gt;imghp.html&lt;/code&gt; which will contain the logic of generating our images and their rendering.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-golang&#34; data-lang=&#34;golang&#34;&gt;{{ &lt;span style=&#34;color:#75715e&#34;&gt;/* The shortcode for HP&amp;#39;s responsive images */&lt;/span&gt; }}

{{&lt;span style=&#34;color:#75715e&#34;&gt;/* get file that matches the filename as specified as src=&amp;#34;&amp;#34;&amp;#34; in shortcode */&lt;/span&gt;}}
{{ &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; (.&lt;span style=&#34;color:#a6e22e&#34;&gt;Site&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;GetPage&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/headless-img&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;Resources&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;GetMatch&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;printf&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;*%s**&amp;#34;&lt;/span&gt; (.&lt;span style=&#34;color:#a6e22e&#34;&gt;Get&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;src&amp;#34;&lt;/span&gt;) }}}

{{&lt;span style=&#34;color:#75715e&#34;&gt;/* set image sizes, these are hardcoded for now, x dictates that images are resized to this width */&lt;/span&gt;}}

{{ &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;tinyw&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;500x&amp;#34;&lt;/span&gt; }}}
{{ &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;smallw&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;800x&amp;#34;&lt;/span&gt; }}}
{{ &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;mediumw&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1200x&amp;#34;&lt;/span&gt; }}}
{{ &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;largew&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1500x&amp;#34;&lt;/span&gt; }}}

{{&lt;span style=&#34;color:#75715e&#34;&gt;/* resize the src image to the given sizes */&lt;/span&gt;}}

{{{.&lt;span style=&#34;color:#a6e22e&#34;&gt;Scratch&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Set&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tiny&amp;#34;&lt;/span&gt; (&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Resize&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;tinyw&lt;/span&gt;) }}
{{{.&lt;span style=&#34;color:#a6e22e&#34;&gt;Scratch&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Set&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;small&amp;#34;&lt;/span&gt; (&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Resize&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;smallw&lt;/span&gt;) }}
{{{.&lt;span style=&#34;color:#a6e22e&#34;&gt;Scratch&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Set&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;medium&amp;#34;&lt;/span&gt; (&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Resize&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;mediumw&lt;/span&gt;) }}
{{{.&lt;span style=&#34;color:#a6e22e&#34;&gt;Scratch&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Set&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;large&amp;#34;&lt;/span&gt; (&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Resize&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;largew&lt;/span&gt;) }}

{{&lt;span style=&#34;color:#75715e&#34;&gt;/* add the processed images to the scratch */&lt;/span&gt;}}

{{&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;tiny&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Scratch&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Get&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tiny&amp;#34;&lt;/span&gt; }}
{{ &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;small&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Scratch&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Get&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;small&amp;#34;&lt;/span&gt; }}
{{ &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;medium&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Scratch&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Get&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;medium&amp;#34;&lt;/span&gt; }}
{{&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;large&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Scratch&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Get&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;wide&amp;#34;&lt;/span&gt; }}

{{&lt;span style=&#34;color:#75715e&#34;&gt;/* only use images smaller than or equal to the src (original) image size, as Hugo will upscale small images */&lt;/span&gt;}}
{{&lt;span style=&#34;color:#75715e&#34;&gt;/* set the sizes attribute to (min-width: 35em) 1200px, 100vw unless overridden in shortcode */&lt;/span&gt;}}

&amp;lt;&lt;span style=&#34;color:#a6e22e&#34;&gt;img&lt;/span&gt; 
{{{&lt;span style=&#34;color:#a6e22e&#34;&gt;with&lt;/span&gt; .&lt;span style=&#34;color:#a6e22e&#34;&gt;Get&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;sizes&amp;#34;&lt;/span&gt; }}&lt;span style=&#34;color:#a6e22e&#34;&gt;sizes&lt;/span&gt;=&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;#39;&lt;/span&gt;{{.}}&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;#39;&lt;/span&gt;{{ &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; }}&lt;span style=&#34;color:#a6e22e&#34;&gt;sizes&lt;/span&gt;=&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;(min-width: 35em) 1200px, 100vw&amp;#34;&lt;/span&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
&lt;span style=&#34;color:#a6e22e&#34;&gt;srcset&lt;/span&gt;=&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;
{{&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ge&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Width&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;500&amp;#34;&lt;/span&gt; }}}
    {{ &lt;span style=&#34;color:#a6e22e&#34;&gt;with&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;tiny&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;RelPermalink&lt;/span&gt; }}{{{.}} &lt;span style=&#34;color:#ae81ff&#34;&gt;500&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;w&lt;/span&gt;{{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ge&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Width&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;800&amp;#34;&lt;/span&gt; }}}
    {{ &lt;span style=&#34;color:#a6e22e&#34;&gt;with&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;small&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;RelPermalink&lt;/span&gt; }}, {{.}} &lt;span style=&#34;color:#ae81ff&#34;&gt;800&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;w&lt;/span&gt;{{{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ge&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Width&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1200&amp;#34;&lt;/span&gt; }}}
    {{ &lt;span style=&#34;color:#a6e22e&#34;&gt;with&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;medium&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;RelPermalink&lt;/span&gt; }}, {{.}} &lt;span style=&#34;color:#ae81ff&#34;&gt;1200&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;w&lt;/span&gt;{{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ge&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Width&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1500&amp;#34;&lt;/span&gt; }}}
    {{&lt;span style=&#34;color:#a6e22e&#34;&gt;with&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;large&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;RelPermalink&lt;/span&gt; }}, {{.}} &lt;span style=&#34;color:#ae81ff&#34;&gt;1500&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;w&lt;/span&gt; {{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;.
{{&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Get&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;medium&lt;/span&gt; }}}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;=&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;{{$medium.RelPermalink }}&amp;#34;&lt;/span&gt; 
{{ &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; }}}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;=&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;{{$src.RelPermalink }}}&amp;#34;&lt;/span&gt; 
{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{{&lt;span style=&#34;color:#a6e22e&#34;&gt;with&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Get&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;alt&amp;#34;&lt;/span&gt; }}&lt;span style=&#34;color:#a6e22e&#34;&gt;alt&lt;/span&gt;=&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;#39;&lt;/span&gt;{{.}}&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;#39;&lt;/span&gt;{{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This template can be found on many sites as an example.&lt;/p&gt;
&lt;p&gt;The main difference with the others is in this line:&lt;br&gt;
&lt;code&gt;{{{$src := (.Site.GetPage &amp;quot;/headless-img&amp;quot;).Resources.GetMatch (printf &amp;quot;*%s*&amp;quot;) (.Get &amp;quot;src&amp;quot;) }}}&lt;/code&gt;&lt;br&gt;
which allows us to retrieve the resources of the &lt;code&gt;headless-img&lt;/code&gt; bundle.&lt;/p&gt;
&lt;p&gt;When this shortcode is executed, it will look for the image defined in the &lt;code&gt;headless-img/index.md&lt;/code&gt; file and automatically generate the declinations.&lt;/p&gt;
&lt;h4 id=&#34;and-now-how-do-i-display-this-on-my-homepage&#34;&gt;And now, how do I display this on my homepage?&lt;/h4&gt;
&lt;p&gt;All we have to do now is call our bundle in our template &lt;code&gt;index.html&lt;/code&gt;.&lt;/p&gt;
&lt;h5 id=&#34;if-you-have-only-one-single-indexmd-index-content&#34;&gt;If you have only one single index.md index content&lt;/h5&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-golang&#34; data-lang=&#34;golang&#34;&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;define&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;content&amp;#34;&lt;/span&gt; }}
  {{ &lt;span style=&#34;color:#75715e&#34;&gt;/* The rendering of the headless section. Assume */&lt;/span&gt; }}
  {{&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;headless&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Site&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;GetPage&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/headless-img&amp;#34;&lt;/span&gt; }}
  {{{&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;headless&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Content&lt;/span&gt; }}
{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h5 id=&#34;if-you-need-to-render-multiplemd-files-based-on-a-name-img1-img2-by-example&#34;&gt;If you need to render multiple.md files based on a name. &lt;code&gt;img1&lt;/code&gt;, &lt;code&gt;img2&lt;/code&gt;&amp;hellip; by example&lt;/h5&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-golang&#34; data-lang=&#34;golang&#34;&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;define&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;content&amp;#34;&lt;/span&gt; }}
  {{&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;headless&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Site&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;GetPage&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/headless-img&amp;#34;&lt;/span&gt; }}
  {{ &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;reusablePages&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;headless&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Resources&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Match&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;img*&amp;#34;&lt;/span&gt; }}
  {{&lt;span style=&#34;color:#66d9ef&#34;&gt;range&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;reusablePages&lt;/span&gt; }}
    {{{.&lt;span style=&#34;color:#a6e22e&#34;&gt;Content&lt;/span&gt; }}}
  {{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
{{&lt;span style=&#34;color:#a6e22e&#34;&gt;end&lt;/span&gt; }}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And that&amp;rsquo;s it, now your images are well rendered on your homepage and their responsive versions are also available.&lt;/p&gt;
&lt;p&gt;Translated with &lt;a href=&#34;http://www.DeepL.com/Translator&#34;&gt;www.DeepL.com/Translator&lt;/a&gt;&lt;/p&gt;
</description>
      
    </item>
    
    <item>
      <title>Manage distinct profiles in Git</title>
      <link>https://gastaud.io/en/article/git-gerer-profils/</link>
      <pubDate>Tue, 02 Apr 2019 00:02:55 +0100</pubDate>
      
      <guid>https://gastaud.io/en/article/git-gerer-profils/</guid>
      
        <description>&lt;p&gt;Translate from French on &lt;a href=&#34;https://dev.to/jygastaud/manage-distinct-profiles-in-git-1b56&#34;&gt;dev.to&lt;/a&gt; and backport here.&lt;/p&gt;
&lt;p&gt;You use your computer to work and, more than ever, you probably use Git (what would you do on this article if not?).&lt;br&gt;
Perhaps you also work on a personal project on the same computer?&lt;br&gt;
Or to contribute to an Open-Source project, always on the same machine.&lt;/p&gt;
&lt;p&gt;You have probably defined a global identity (name + email) for your machine and overloaded it for each project according to the context.&lt;/p&gt;
&lt;p&gt;Perfect! Perfect!&lt;/p&gt;
&lt;p&gt;And yet despite these usual precautions, who has never commited in a project with a wrong identity?
Sometimes you may find this out late and your personal email is now &lt;em&gt;ad vitam æternam&lt;/em&gt; in the project logs.&lt;/p&gt;
&lt;p&gt;So how can we try to limit the risk of errors?&lt;/p&gt;
&lt;p&gt;Could we automate the selection of the right identity for our projects?&lt;/p&gt;
&lt;p&gt;Well, the good news is that &lt;strong&gt;the answer is YES&lt;/strong&gt; and we&amp;rsquo;ll see how right after that.&lt;/p&gt;
&lt;h2 id=&#34;gitconfig-and-conditional-includes-thanks-to-includeif&#34;&gt;.gitconfig and conditional includes thanks to IncludeIf&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s take the file &lt;code&gt;.gitconfig&lt;/code&gt;, usually present in your &lt;code&gt;$HOME&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;[user]
	name = Jean-Yves Gastaud
	email = mon.super@mail.com

[alias]
  amend = commit --amend
  st = status
  co = checkout
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This file defines our default identity and global aliases.&lt;/p&gt;
&lt;p&gt;Thanks to the use of the &lt;code&gt;includeIf&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; directive in our &lt;code&gt;.gitconfig&lt;/code&gt; file, we can now add conditional includes linked, especially to directories.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;[includeIf &amp;quot;gitdir:/workspace/work/&amp;quot;]
  path = ~/.gitconfig-work

[includeIf &amp;quot;gitdir:/workspace/opensource/&amp;quot;]
  path = ~/.gitconfig-opensource

[includeIf &amp;quot;gitdir:/workspace/perso/&amp;quot;]
  path = ~/.gitconfig-perso
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;For each defined &lt;code&gt;includeIf&lt;/code&gt;, all we have to do is create the file corresponding to the path we defined in &lt;code&gt;path&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In the &lt;code&gt;~/.gitconfig-work&lt;/code&gt; file, we only have to add or override the configurations we are interested in.&lt;/p&gt;
&lt;p&gt;Example :&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;[user]
        email = my.work@mail.com

[core]
        editor = &amp;quot;code -w&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this file, we overload our email and add a default code editor.&lt;/p&gt;
&lt;p&gt;Now, any folder under the &lt;code&gt;/workspace/work&lt;/code&gt; directory will automatically benefit from loading the configuration of the &lt;code&gt;.gitconfig&lt;/code&gt; file, overloading or supplementing with those of the &lt;code&gt;.gitconfig-work&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;To check your configuration, go to any directory under the target directory, &lt;code&gt;/workspace/work&lt;/code&gt; in our example and run the command &lt;code&gt;git config -l&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You should see the merging of your config files.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;user.name=Jean-Yves Gastaud
email = my.super@mail.com
alias.amend=commit --amend
alias.st=status
alias.co=checkout
includeif.gitdir:/workspace/work/work/.path=~/.gitconfig-work
user.email=my.work@mail.com
core.editor=code -w
includeif.gitdir:/workspace/opensource/.path=~/.gitconfig-opensource
includeif.gitdir:/workspace/perso/.path=~/.gitconfig-perso
core.repositoryformatversion=0
core.filemode=true
…
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As you can see, the 2 defined emails are present in the listing.&lt;br&gt;
The last &amp;ldquo;speaking&amp;rdquo; being right, it is therefore the value of the file &lt;code&gt;.gitconfig-work&lt;/code&gt; which will be considered during the commit.&lt;/p&gt;
&lt;p&gt;You will also notice that the other 2 include are listed but do not add new variables / overloads because their application condition is not met.&lt;/p&gt;
&lt;p&gt;This always gives us the possibility to overload, locally at the repository, all desired configurations, as before.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In a few lines and a simple management of your working directories, it is therefore possible for you to no longer risk making mistakes in changing your identities.&lt;/strong&gt;&lt;/p&gt;
&lt;section class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;Since Git, version 2.13 (2017, May). [Documentation on Includes in Git] (&lt;a href=&#34;https://git-scm.com/docs/git-config#_includes&#34;&gt;https://git-scm.com/docs/git-config#_includes&lt;/a&gt;)&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</description>
      
    </item>
    
  </channel>
</rss>