<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adam Jolicoeur</title>
    <description>The latest articles on DEV Community by Adam Jolicoeur (@adamj).</description>
    <link>https://dev.to/adamj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F495040%2Fbf2dfe18-676e-4be2-bde8-43060fdfda27.jpg</url>
      <title>DEV Community: Adam Jolicoeur</title>
      <link>https://dev.to/adamj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adamj"/>
    <language>en</language>
    <item>
      <title>Upgrading to Eleventy v3.0 (beta)</title>
      <dc:creator>Adam Jolicoeur</dc:creator>
      <pubDate>Tue, 17 Sep 2024 17:08:30 +0000</pubDate>
      <link>https://dev.to/adamj/upgrading-to-eleventy-v30-beta-je</link>
      <guid>https://dev.to/adamj/upgrading-to-eleventy-v30-beta-je</guid>
      <description>&lt;h2&gt;
  
  
  Jumping in
&lt;/h2&gt;

&lt;p&gt;I took the plunge today and upgraded my site &lt;a href="https://www.adamjolicoeur.com" rel="noopener noreferrer"&gt;adamjolicoeur.com&lt;/a&gt; to the Eleventy v3.0 beta. I've been following along with the progress of v3 since it was announced and, with the &lt;a href="https://www.11ty.dev/blog/eleventy-font-awesome/" rel="noopener noreferrer"&gt;latest news&lt;/a&gt; that Eleventy will be joining the team behind Font Awesome, felt that this was a good time to take the plunge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting the process
&lt;/h2&gt;

&lt;p&gt;What better place to start than 11ty.com? Scrolling towards the bottom, I found the link in the "&lt;a href="https://www.11ty.dev/#news-from-the-blog" rel="noopener noreferrer"&gt;News from the blog&lt;/a&gt;" section, which took me to the blog post, which I then used to get to the GitHub page specific to the &lt;a href="https://github.com/11ty/eleventy/releases/tag/v3.0.0-beta.1" rel="noopener noreferrer"&gt;Eleventy v3.0.0-beta.1&lt;/a&gt; release notes. From there, I followed the instructions of installing the beta and then the &lt;a href="https://github.com/11ty/eleventy-upgrade-help" rel="noopener noreferrer"&gt;migration plugin&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @11ty/eleventy@beta
npm install @11ty/eleventy-upgrade-help@3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The instructions in the &lt;code&gt;eleventy-upgrade-help&lt;/code&gt; plugin state to install @11ty/eleventy@3 yet there is no @3 version. Replace &lt;code&gt;@3&lt;/code&gt; with &lt;code&gt;@beta&lt;/code&gt; to use the beta release.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrading
&lt;/h2&gt;

&lt;p&gt;After installing the required dependencies, a simple update to my &lt;code&gt;.eleventy.js&lt;/code&gt; file was needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const UpgradeHelper = require("@11ty/eleventy-upgrade-help");

module.exports = function(eleventyConfig) {
  // If you have other `addPlugin` calls, UpgradeHelper should be listed last.
  eleventyConfig.addPlugin(UpgradeHelper);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Upgrade Plugin Placement
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;In my case, I added &lt;code&gt;eleventyConfig.addPlugin(UpgradeHelper);&lt;/code&gt; above the &lt;code&gt;eleventyConfig.setBrowserSyncConfig({&lt;/code&gt; section, which contains my local browser configuration and is followed by library configuration settings.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frstf6p3237y7qhlwkwvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frstf6p3237y7qhlwkwvk.png" alt="Screenshot of where the upgrade helper plugin was added" width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After those updates were made, I proceeded to run both &lt;code&gt;npm run build&lt;/code&gt; and &lt;code&gt;npm start&lt;/code&gt; in order to build the initial files before starting up my local development server. (The instructions stated to run &lt;code&gt;npm build&lt;/code&gt; but, knowing how my environment is configured, I knew that both prompts were needed.)&lt;/p&gt;

&lt;h2&gt;
  
  
  On your mark, get set, migrate!
&lt;/h2&gt;

&lt;p&gt;Now that my environment was configured, it was time to kick off the migration from v2 to v3. I quickly realized though, that when updating &lt;code&gt;.eleventy.js&lt;/code&gt;, that I had placed the &lt;em&gt;UpgradeHelper&lt;/em&gt; plugin in the wrong area of the file. If done correctly, you should see the following in your prompt:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgc2wy76lnj48xtxhjo8j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgc2wy76lnj48xtxhjo8j.png" alt="Screenshot of the command prompt with Eleventy Upgrade Guide passing checks" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unfortunately, I received this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyfvl6eevepdal7ypx3ep.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyfvl6eevepdal7ypx3ep.png" alt="Screenshot of the command prompt with error messages" width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Realizing that I was not getting to the &lt;em&gt;UpgradeHelper&lt;/em&gt; while also receiving a new v3 error, I rechecked my configuration file (see upgrade plugin placement) and added a new line to bypass this error: &lt;code&gt;eleventyConfig.setFreezeReservedData(false);&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F811zwnsvmevck97k3pka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F811zwnsvmevck97k3pka.png" alt="Screenshot showing placement of bypass code" width="800" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Plugin Output
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdar5r06nlkb2qdr9bm82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdar5r06nlkb2qdr9bm82.png" alt="Screenshot of the output from the Upgrade Plugin" width="800" height="778"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're seeing output similar to what is shown in the screenshot above, you're on the right path! For me, the most important output was seeing &lt;code&gt;[11ty/eleventy-upgrade-help] This plugin is intended for temporary use: once you’re satisfied please remove this plugin from your project.&lt;/code&gt;. This told me that the plugin had been run and that any issues would (or should) be caught and thrown.&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional output messages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[11ty/eleventy-upgrade-help] PASSED All of your project’s .html output files (×0) are using &amp;lt;meta name="generator" content="Eleventy …"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Informs the reader that all files are using the correct &lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt; information for Eleventy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[11ty/eleventy-upgrade-help] PASSED Eleventy will fail with an error when you point --config to a configuration file that does not exist. You are not using --config —so don’t worry about it! Read more: https://github.com/11ty/eleventy/issues/3373
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let me know that my configuration file is in good shape while also telling me what to avoid using.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[11ty/eleventy-upgrade-help] PASSED You aren’t using --formats= or  --formats='' but if you were you should know that these are now empty template format sets. In previous versions, they were aliased to "*". Read more: https://github.com/11ty/eleventy/issues/3255
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Informing me that I do not have any empty format sets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[11ty/eleventy-upgrade-help] PASSED No {pug,ejs,haml,mustache,handlebars} templates were found in this project. If you were, you would have needed to install plugins for these: https://github.com/11ty/eleventy-plugin-template-languages. Learn more: https://github.com/11ty/eleventy/issues/3124
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The upgrader checked for any files other than Markdown (&lt;code&gt;.md&lt;/code&gt;) or (&lt;code&gt;/html&lt;/code&gt;), which would require an additional plugin. None were found, so that plugin is not needed.&lt;/p&gt;

&lt;p&gt;These are only a few of the messages that were given by the upgrade plugin - each one was informational and provided references to GitHub issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;The upgrade from Eleventy v2 to Eleventy v3 was fairly straightforward and simple to incorporate into my site. There was a noticeable improvement in build time and responsiveness in the process. As part of the completed build, the final line was as follows: &lt;code&gt;Copied 150 Wrote 27 files in 0.11 seconds (v3.0.0-beta.1)&lt;/code&gt;. Not bad at all!&lt;/p&gt;

&lt;p&gt;Once the final release drops, I'll be sure to go full v3. My site builds cleanly, fast, and I'll be able to simplify things moving forward.&lt;/p&gt;




&lt;p&gt;If you have any questions, feel free to drop them in the comments below and I'll answer as best I can! Thanks for reading!&lt;/p&gt;

</description>
      <category>eleventy</category>
      <category>webdev</category>
      <category>portfolio</category>
    </item>
    <item>
      <title>Setting active state on navigation with Eleventy</title>
      <dc:creator>Adam Jolicoeur</dc:creator>
      <pubDate>Thu, 21 Sep 2023 18:07:31 +0000</pubDate>
      <link>https://dev.to/adamj/setting-active-state-on-navigation-with-eleventy-hhe</link>
      <guid>https://dev.to/adamj/setting-active-state-on-navigation-with-eleventy-hhe</guid>
      <description>&lt;p&gt;In creating my portfolio site, I wanted to have dynamic elements that would add/remove classes based on the site's structure, as well as the page content. The first step in this was the navigation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;Setting the &lt;code&gt;active&lt;/code&gt; class to be applied when parsing through my collections, and having it only apply to particular a page, was just not working. I tried using various properties such as &lt;code&gt;tag&lt;/code&gt;, &lt;code&gt;title&lt;/code&gt;, and even the eleventyNavigation plugin.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nx"&gt;navPages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;collections&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;all&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;eleventyNavigation&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;navbar-nav col-md-6 justify-content-md-center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;navbar-brand col-md-1 me-0 text-center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{{ &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;navbar&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;png&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; | url }}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Avatar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;32&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;32&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;%-&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;navPages&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;nav-link&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{{ entry.url }}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{{entry.description}}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&amp;gt; #&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;nav-link {{ 'active' if 'entry.title' in entry.url }}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{{ entry.url }}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{{ entry.abbreviation }}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;%-&lt;/span&gt; &lt;span class="nx"&gt;endfor&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No matter what I tried, nothing would set the active state of the page to the proper one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution (easy way out)
&lt;/h2&gt;

&lt;p&gt;After stumbling around through various #eleventy guides, I came across various implementations of the &lt;code&gt;&amp;lt;% if %&amp;gt;&lt;/code&gt; statement, but none of them ever worked for me. In the end, I decided to simplify my navigation to, instead of using &lt;code&gt;collections&lt;/code&gt;, fall back to the tried and true individual &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; for each navigation item. This allowed me to utilize the &lt;code&gt;&amp;lt;% if %&amp;gt;&lt;/code&gt; statement to look for a specific location and, if the URL contained that string, apply the &lt;code&gt;active&lt;/code&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;nav-link {% if '/designs' in page.url %}active{% endif %}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/designs&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Link to Designs that I have created and worked on.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;designs&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This now applies the &lt;code&gt;active&lt;/code&gt; class to any page that has &lt;code&gt;/designs&lt;/code&gt; in the URL. No longer am I reliant on the collections information being read, nor am I having to worry about a page ending up on the wrong place and applying the class incorrectly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;Ideally, I would be able to set my site to read through all of the items in my &lt;code&gt;collections&lt;/code&gt; and then parse through that information to apply the &lt;code&gt;active&lt;/code&gt; class correctly. As I build out my site and want to rely less on manually updating the navigation, this will become paramount (looking at you, breadcrumbs).&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;If you found this short bit of information helpful, let me know in the comments or by adding a reaction. If you have any suggestions, I'm open to hearing any and all!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/AdamJ/AdamJ.github.io/tree/main" rel="noopener noreferrer"&gt;View source on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>eleventy</category>
      <category>11ty</category>
      <category>tutorial</category>
      <category>portfolio</category>
    </item>
  </channel>
</rss>
