Skip to content

Instantly share code, notes, and snippets.

@henshaw
henshaw / schema-profilepage.js
Last active November 29, 2023 05:26
Detailed ProfilePage Schema example
View schema-profilepage.js
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "ProfilePage",
"dateCreated": "2019-12-23T12:34:00-05:00",
"dateModified": "2019-12-26T14:53:00-05:00",
"mainEntity": {
"@type": "Person",
"@id": "https://www.coywolf.news/jon-henshaw#Person",
"name": "Jon Henshaw",
@henshaw
henshaw / rei-sponsored-pattern-matching.js
Created October 29, 2023 17:08
Pattern matching event tracking with Fathom Analytics
View rei-sponsored-pattern-matching.js
<script>
document.querySelectorAll('[rel="sponsored"]').forEach(item => {
item.addEventListener('click', event => {
let linkUrl = new URL(item.getAttribute('href'), window.location.href);
// Using the second argument to handle relative URLs
let currentHostname = window.location.hostname;
if (linkUrl.hostname !== currentHostname) {
// If the link's hostname is different from the current page's hostname
let domainParts = linkUrl.hostname.split('.');
let domainName = domainParts.length > 1 ? domainParts[domainParts.length - 2] : domainParts[0];
@henshaw
henshaw / lazy-loading-image.html
Created October 4, 2023 21:31
Native image lazy loading
View lazy-loading-image.html
<img src="https://domain.com/image.png" loading="lazy" alt="Image description">
@henshaw
henshaw / disallow-genai-bots.txt
Last active October 28, 2023 20:13
Disallow all pages from being trained for LLMs by all major GenAI bots
View disallow-genai-bots.txt
User-agent: GPTBot
Disallow: /
User-agent: CCBot
Disallow: /
User-agent: ChatGPT-User
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: Omgilibot
Disallow: /
@henshaw
henshaw / google-extended-folder.txt
Created September 29, 2023 05:31
Disallow specific folders from being used to train Google LLMs
View google-extended-folder.txt
User-agent: Google-Extended
Disallow: /folder
@henshaw
henshaw / google-extended-all.txt
Created September 29, 2023 05:30
Disallow all pages from being used to train Google LLMs
View google-extended-all.txt
User-agent: Google-Extended
Disallow: /
@henshaw
henshaw / rss-feed-link-example.html
Created September 16, 2023 17:25
RSS feed link example
View rss-feed-link-example.html
@henshaw
henshaw / gravatar-alt-text.php
Last active September 3, 2023 01:31
Add ALT text to gravatar image in byline
View gravatar-alt-text.php
// If you use this Gravatar code in your WordPress templates
<?php echo get_avatar( get_the_author_meta( 'ID' ), 60); ?>
// Add this to functions.php to include ALT text with the image
function gravatar_alt($text) {
$alt = get_the_author_meta( 'display_name' );
$text = str_replace('alt=\'\'', 'alt=\'Headshot for '.$alt.'\'',$text);
return $text;
}
add_filter('get_avatar','gravatar_alt');
@henshaw
henshaw / schema-person.js
Last active August 28, 2023 23:18
Detailed Person Schema example
View schema-person.js
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Person",
"@id": "https://www.coywolf.news/jon-henshaw#Person",
"name": "Jon Henshaw",
"givenName": "Jonathan",
"familyName": "Henshaw",
"additionalName": "Michael",
"nationality":{
@henshaw
henshaw / close.html
Created July 22, 2023 14:38
JavaScript and HTML used to show and hide Close icon
View close.html
<!-- JS for displaying and hiding "Close" icon -->
<script>
function navopen() {
var x = document.getElementById("close");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}