LitKnd / littlekendracomments

1 stars 0 forks source link

Post: How I Got Twitter Cards Working in Hugo with the Mainroad theme #25

Open LitKnd opened 3 years ago

LitKnd commented 3 years ago

Comments left here will appear on http://www.littlekendra.com/2021/05/07/how-i-got-twitter-cards-working-hugo-mainroad/

robguilarr commented 2 years ago

So useful, just fixed my website! Thanks.

dlcasto commented 2 years ago

Thanks for the tips! I discovered that Twitter Cards do not support relative URLs. I enabled relativeURLs = true in my config.toml since I have a local GitLab instance installed on my server with GitLab Pages enabled. My local GitLab Pages would not render properly with the baseURL of my public website since the local URL is different. Because I want a local deployment for development purposes, I had to update my front matter to include the full URL for the images parameter. It's a bit ugly but allows everything to work properly on my local and public website:

images:
- https://mypublicwebsite.com/post/image.jpg
JeffersGlass commented 2 years ago

Thank you for this! Very helpful to have a practical example. As @dlcasto said, I also could not get relative urls working for twitter cards, so I also hardcoded the image links. Not too onerous for a small site, but never would have found that solution if not for this post.