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 →

two simple http server tools

http-server install: npm install -g http-server start the server with http-server reference: NodeJS - Setup a Simple HTTP Server / Local Web Server browser-sync install: npm install -g browser-sync start the server with browser-sync start --server Read more →

Can’t display svg file when host on aws s3

.svg 文件上传到 aws s3 + cloudfront 时,有可能在网页上显示不出来,通过 chrome inspect 看的话,该 svg 的 content-type 并不是 image/svg+xml 。 解决办法是在 aws s3 网页上,选中该 svg 文件,右键 -> Properties -> Metadata 中将 content-type 改为 image/svg+xml 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 →

如何查看浏览器中文字当前在用的字体?

在 CSS 代码中会在 font-family 中指定了好几个字体,但最终用的是哪个字体呢? 在 Chrome 中,Inspect -> Element -> 右侧的 Computed -> 拉到最下面Rendered Fonts 参考链接:How can I determine what font a browser is actually using to render some text? Read more →

apache2 ssl configulation subdomain

Environment: Ubuntu 16.04, Apache 2.4.18, 主域名已经配置好了 ssl ,想给一个二级域名配置 ssl ,证书从 sslforfree.com 那配置下载后,上传到 /etc/apache2/ssl ,在 /etc/apache2/sites-available 里复制主域名已经配置好的 conf 进行修改,见下图。 我不太确定上面的三个 是否需要删除。 然后需要敲下面一个命令,它会在 /etc/apache2/sites-enabled 生成一个软链接(应该是软链接吧) 然后重启一下 apache  Force http to https这个配置需要在另一个 conf 里配置,即对应二级域名的 80 的 conf 里配置,加多下面三行。 完事的 config 见下面       Read more →

sslforfree wildcard Certificates https SSL

第一次用 sslforfree.com 的 wildcard 功能,成功。之前没倒腾成功。 在输入框内输入的是 *.linminquan.com linminquan.com ,要求验证的是两个 DNS TXT 记录。 之前一直不理解为什么是同样的一个 _acme-challenge.linminquan.com 要 DNS TXT 到两个不同的值,只好按它的要求操作,后来居然是可以的。 验证时,第一行有显示 TXT Record(s) Found. 就可以了。 chrome 中查看生效要过一会。 Read more →

js解析url

解析 URL Params 为对象,例如 ‘http://www.domain.com/?user=anonymous&id=123&id=456&city=%E5%8C%97%E4%BA%AC&enabled’ parseParam(url) 才注意到 js 里有个专门用来处理 url 的 object, URL   Read more →