<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>hugo | Steve Linberg</title><link>https://slinberg.net/tag/hugo/</link><atom:link href="https://slinberg.net/tag/hugo/index.xml" rel="self" type="application/rss+xml"/><description>hugo</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Thu, 27 May 2021 00:00:00 +0000</lastBuildDate><image><url>https://slinberg.net/media/icon_hua2ec155b4296a9c9791d015323e16eb5_11927_512x512_fill_lanczos_center_2.png</url><title>hugo</title><link>https://slinberg.net/tag/hugo/</link></image><item><title>Adding "Edit this page" links</title><link>https://slinberg.net/post/adding-edit-this-page-links/</link><pubDate>Thu, 27 May 2021 00:00:00 +0000</pubDate><guid>https://slinberg.net/post/adding-edit-this-page-links/</guid><description>&lt;p>Here&amp;rsquo;s how the cool Hugo/&lt;a href="https://wowchemy.com/" target="_blank" rel="noopener">Wowchemy&lt;/a> kids add those groovy &amp;ldquo;Edit this page&amp;rdquo; elements to their pages in the &lt;a href="https://github.com/wowchemy/starter-hugo-academic" target="_blank" rel="noopener">academic-starter&lt;/a> theme:&lt;/p>
&lt;p>In &lt;code>config/_default/params.yaml&lt;/code>, find the section &lt;code>edit_page&lt;/code> and:&lt;/p>
&lt;p>☞︎ Set &lt;code>repo_url&lt;/code> to the URL of your repository (here, github)&lt;br>
☞︎ Set &lt;code>content_dir&lt;/code> to the directory of your site&amp;rsquo;s content, &lt;code>content&lt;/code> by default)&lt;br>
☞︎ Set &lt;code>repo_branch&lt;/code> to your repo&amp;rsquo;s published branch; I use &lt;code>master&lt;/code> rather than &lt;code>main&lt;/code>)&lt;/p>
&lt;p>Then set the &lt;code>editable&lt;/code> fields as needed for the types of content you want these links to be present in.&lt;/p>
&lt;p>Here&amp;rsquo;s the code from this site:&lt;/p>
&lt;pre>&lt;code class="language-yaml">edit_page:
repo_url: 'https://github.com/slinberg-umass/slinberg.net'
content_dir: 'content'
repo_branch: master
editable:
page: true
post: true
book: true
&lt;/code>&lt;/pre>
&lt;p>That&amp;rsquo;s all you need to do; when you rebuild, if the &lt;code>edit_page&lt;/code> parameters are not empty, Hugo will insert the link as directed by the templates. This is the bit of triggering code:&lt;/p>
&lt;pre>&lt;code class="language-hugo">{{ partial &amp;quot;page_edit&amp;quot; . }}
&lt;/code>&lt;/pre>
&lt;p>It is contained in various inherited templates such as &lt;code>themes/github.com/wowchemy/wowchemy-hugo-modules/wowchemy/layouts/partials/page_footer.html&lt;/code>, and the code is in &lt;code>themes/github.com/wowchemy/wowchemy-hugo-modules/wowchemy/layouts/partials/page_edit.html&lt;/code>.&lt;/p>
&lt;p>Look at the code to see, among other things, that it can be overridden on a specific page or post by adding &lt;code>editable: false&lt;/code> to its &lt;code>yaml&lt;/code> header.&lt;/p>
&lt;p>But we&amp;rsquo;re not doing that in this case, so falling off the bottom of the content here, we get the groovy link to the page source below (note, you&amp;rsquo;ll need to fork the repo to actually see it, it&amp;rsquo;s more for me than for you):&lt;/p></description></item><item><title>Testing a new shortcode</title><link>https://slinberg.net/post/testing-a-new-shortcode/</link><pubDate>Thu, 20 May 2021 00:00:00 +0000</pubDate><guid>https://slinberg.net/post/testing-a-new-shortcode/</guid><description>&lt;p>Let&amp;rsquo;s see if we can get &lt;a href="https://discourse.gohugo.io/t/howto-youtube-embed-with-custom-start-time/7060/6" target="_blank" rel="noopener">this shortcode&lt;/a> working, which will allow us to embed a YouTube video with a start and end time.&lt;/p>
&lt;p>Here is Chris Bail, introducing topic models, dropping some knowledge about setting explicit seeds for reproducible results. I want friends who do topic models.&lt;/p>
&lt;div style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;">
&lt;iframe src="https://www.youtube-nocookie.com/embed/IUAHUEy1V0Q?start=518&amp;end=537"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" allowfullscreen frameborder="0" title="YouTube Video">&lt;/iframe>
&lt;/div>
&lt;p>&lt;br />&lt;/p>
&lt;p>The shortcode file &lt;code>youtubestartend.html&lt;/code> contains:&lt;/p>
&lt;pre>&lt;code class="language-html">&amp;lt;!-- https://discourse.gohugo.io/t/howto-youtube-embed-with-custom-start-time/7060/6 --&amp;gt;
&amp;lt;div style=&amp;quot;position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;&amp;quot;&amp;gt;
&amp;lt;iframe src=&amp;quot;http://www.youtube-nocookie.com/embed/{{ index .Params 0 }}?start={{ index .Params 1 }}&amp;amp;end={{ index .Params 2}}&amp;quot;
style=&amp;quot;position: absolute; top: 0; left: 0; width: 100%; height: 100%;&amp;quot; allowfullscreen frameborder=&amp;quot;0&amp;quot; title=&amp;quot;YouTube Video&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code>&lt;/pre>
&lt;p>and is placed in the directory &lt;code>layouts/shortcodes/blogdown/&lt;/code>.&lt;/p>
&lt;p>The embedded code, used above, is:&lt;/p>
&lt;pre>&lt;code class="language-r">{{&amp;lt; blogdown/youtubestartend IUAHUEy1V0Q 518 539 &amp;gt;}}
&lt;/code>&lt;/pre>
&lt;p>&amp;hellip;and incidentally, the way you present the above code, without having the shortcode actually rendered by Hugo, is explained &lt;a href="https://www.ii.com/hugo-tips-fragments/#_11_escaping_hugo_shortcodes" target="_blank" rel="noopener">in this Infinite Ink post&lt;/a>. Basically, you put the entire shortcode between &lt;code>/* C comment delimiters */&lt;/code>:&lt;/p>
&lt;pre>&lt;code class="language-r">{{&amp;lt;/* blogdown/youtubestartend IUAHUEy1V0Q 518 539 */&amp;gt;}}
&lt;/code>&lt;/pre>
&lt;p>&amp;hellip;and to render THAT text above, you have to do double delimiters:&lt;/p>
&lt;pre>&lt;code class="language-r">{{&amp;lt;/*/* blogdown/youtubestartend IUAHUEy1V0Q 518 539 */*/&amp;gt;}}
&lt;/code>&lt;/pre>
&lt;p>&amp;hellip;and so forth.&lt;/p></description></item></channel></rss>