LinMinquan's Blog

Experience technology to change life

Hugo add meta for Facebook and Twitter share link preview

After analyze a example link that can preview in Facebook & Twitter and search Google, I found it just need to add some meta on blog post’s html header. One guy give an example code below. His blog post about this solution: https://vietlq.github.io/2017/04/30/access-hugo-page-variables/His github gist about this code: https://gist.github.com/vietlq/d1c7ecfb20ce7beac4a7f4df746c797cReference: <a rel=“noreferrer noopener” aria-label=“Reference: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary.html https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup.html  (opens in a new tab)” href=“https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary.html" target="_blank”>https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary.html<a rel=“noreferrer noopener” aria-label=“Reference: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary.html https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup.html  (opens in a new tab)” href=“https://developer. Read more →

Hugo, Front Matter Variable, Type

Hugo V40.2 Hugo 的 Front Matter Variable有一个是 Type,它的默认值是这篇 post 所在的 directory ,如果这篇 post (假设文件名为 aaa.md ) 所在的目录是 blog ,那它最终的 url 是 xxx.com/blog/aaa/ ,而 Type 可以修改其中的 blog 为其它字符。 我遇到的问题是我的 posts 都是从网站(基于 WordPress )上用插件导出来的,这样每个 post (markdown file) 里的 Front Matter 会有 Type: posts 的属性。有这个设置使得这些 posts (markdown file) 的 template 是基于 posts template ,但这些 posts (markdown file) 其实是放在 blog 目录下的,按照我原来的理解,放在 哪个目录下(例如 blog ),其 template 是基于哪个 template 的(放在 blog 下,就基于 blog template )。但其实这个是可以被 type 这个 Front Matter 给 override 的。 Read more →

Hugo pagination bootstrap4

Hugo V40.2 , Bootstrap 4.1.1 在做 pagination 时,Hugo 文档说可以用内置的跟 Bootstrap 兼容的一个 pagination ,但我在用的时候,出来的样式不对。我看 Jimmysong的 博客源码,他用的就是官方说的内置的 pagination ,但他用的是 Bootstrap3 。 搜了下,有人也发现了 Hugo 说的跟 Bootstrap 兼容的 pagination 只是跟 Bootstrap3 兼容,而不是跟 Bootstrap4 兼容,并给出了解决办法。 Hugo Pagination Partial for Bootstrap4 Read more →